Skip to content

Prevent lost remote table attribute updates during broadcast - #19546

Merged
JackieTien97 merged 2 commits into
masterfrom
ty/fix-table-attribute-batches
Dec 6, 2026
Merged

JackieTien97 merged 2 commits into
masterfrom
ty/fix-table-attribute-batches

Conversation

@JackieTien97

Copy link
Copy Markdown
Contributor

Problem

An exact-device query can keep returning an old table ATTRIBUTE after a SchemaRegion migration. In a two-DataNode cluster, warm the device attribute caches, move the single schema replica to the other DataNode, and run the following statements against the table used by IoTDBTableTagSchemaMigrationIT.

UPDATE tag_key SET model = 'empty-updated'
WHERE site = 'north' AND device = 'legacy' AND zone = '';
UPDATE tag_key SET model = 'tagged-updated'
WHERE site = 'north' AND device = 'legacy' AND zone = 'z1';
SELECT model, reading FROM tag_key
WHERE site = 'north' AND device = 'legacy' AND zone = 'z1';

If the last write completes after the broadcaster serializes the preceding batch but before it samples the version, both batches carry version 3. The receiving DataNode discards the second batch and acknowledges the RPC. The sender clears the pending update. In a controlled reproduction, the former replica still returned (z1, 14) and (z1, 15) after two broadcast intervals. The new leader returned (tagged-updated, 14) and (tagged-updated, 15).

Changes

  • Capture the SchemaRegion version before serializing a batch.
  • Invalidate the devices named by an equal-version detail batch. Size-limited batches can share a version, and invalidation lets the next read fetch current attributes without replaying stale values from a retry.
  • Queue the invalidation behind outstanding schema fetches and register each fetch atomically with queue processing.

Verification

Both new regression tests failed against the previous implementation. With the fix, all 16 targeted DataNode unit tests and all five integration tests passed, including schema migration, delayed updates and degraded attribute backlogs. With the same serialization interleaving, the two batches carried versions 2 and 3 and both DataNodes returned the updated attribute on the first check. The full English and Chinese package builds also passed.

@codecov

codecov Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.96970% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 51.07%. Comparing base (4833668) to head (4d52dcc).

Files with missing lines Patch % Lines
.../update/GeneralRegionAttributeSecurityService.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #19546      +/-   ##
============================================
+ Coverage     51.05%   51.07%   +0.01%     
  Complexity      145      145              
============================================
  Files          5797     5797              
  Lines        430459   430461       +2     
  Branches      57371    57373       +2     
============================================
+ Hits         219782   219858      +76     
+ Misses       210677   210603      -74     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

A DataNode can lead several table SchemaRegions. Keep scanning after an empty region result so the remaining leaders can send their pending updates in the same round.

Verify remote attribute reads across three databases on two DataNodes and cover migration version restoration for fetched regions.
@sonarqubecloud

sonarqubecloud Bot commented Dec 6, 2026

Copy link
Copy Markdown

@JackieTien97
JackieTien97 merged commit 29bc0e5 into master Dec 6, 2026
42 checks passed
@JackieTien97
JackieTien97 deleted the ty/fix-table-attribute-batches branch December 6, 2026 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant