Skip to content

Guard subscription batch snapshots against concurrent updates - #19116

Open
Caideyipi wants to merge 1 commit into
masterfrom
codex/fix-subscription-poll-hashmap-race
Open

Caideyipi wants to merge 1 commit into
masterfrom
codex/fix-subscription-poll-hashmap-race

Conversation

@Caideyipi

Copy link
Copy Markdown
Collaborator

Summary

Subscription polling and batch emission copy regionIdToBatch.keySet() while the prefetch path may structurally update the same map under per-region locks. A concurrent update can make the snapshot fail and abort polling.

Use ConcurrentHashMap for region batch tracking while retaining the existing per-region locks for batch operations. Add a regression test that runs poll and emit snapshots alongside prefetch-style inserts and removals.

Validation

  • mvn spotless:apply -P with-integration-tests -pl iotdb-core/datanode
  • mvn -o -pl iotdb-core/datanode -am clean test -Dtest=SubscriptionPipeEventBatchesConcurrencyTest -Dsurefire.failIfNoSpecifiedTests=false (28 reactor modules; 1 test passed)

@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@Caideyipi
Caideyipi marked this pull request as ready for review November 4, 2026 03:39

@Caideyipi Caideyipi left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial independent self-review for PR head d392b0b against master.

The complete diff and relevant subscription batch, segment-lock, and prefetch queue lifecycle paths were inspected. No actionable issues were found, and no fixes were needed. The ConcurrentHashMap change safely supports concurrent region-key snapshots while preserving the existing per-region locks.

Local verification: the newly added concurrency regression test was reported passing locally; it was not rerun during this review round. The local checkout remained master at 65ef92f; the confirmed remote PR head is d392b0b.

@codecov

codecov Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 48.28%. Comparing base (65ef92f) to head (d392b0b).

Files with missing lines Patch % Lines
...tion/event/batch/SubscriptionPipeEventBatches.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #19116      +/-   ##
============================================
- Coverage     48.29%   48.28%   -0.01%     
  Complexity      625      625              
============================================
  Files          5572     5572              
  Lines        411719   411719              
  Branches      54229    54229              
============================================
- Hits         198820   198798      -22     
- Misses       212899   212921      +22     

☔ 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.

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.

2 participants