Mryange opened a new pull request, #71267:
URL: https://github.com/apache/doris/pull/71267

   ### Background
   
   Each BE keeps a shared visible-version record for the tablets of a 
partition. Compaction reads the version and the time of its last advance to 
choose how many invisible versions to retain.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #28082 (introduced visible-version tracking for compaction)
   PR Type: Bugfix
   
   Problem Summary:
   
   A partition update can publish a new visible version before updating its 
timestamp. Compaction can race with the timestamp write and observe the new 
version with the preceding timestamp, selecting the wrong retention window. 
Protect the version and timestamp with one per-partition mutex so that each 
read sees a consistent pair.
   
   ### Details
   
   - **Frequency:** Intermittent. ThreadSanitizer observed an overlap between a 
partition version update and a compaction read. The rate of production impact 
is unknown.
   - **Root cause:** An atomic version CAS and an ordinary timestamp store were 
separate operations in a shared object. The update and compaction paths could 
access that object under different outer locks.
   - **Why existing tests missed it:** The changelog compaction unit tests seed 
a version and read it sequentially. The Docker visible-version compaction suite 
exercises the retention policy and reads older versions without controlling 
concurrent access to the BE state.
   - **Fix:** Read and write both fields under the same mutex. The timestamp 
advances only when the version increases. Duplicate and delayed updates 
preserve the pair. Partition reporting uses the synchronized accessor.
   - **Other paths and branches:** The FE update and engine clone paths 
converge on the same holder. The release branches 3.1, 4.0, 4.1, and 4.2 
contain the split publication by source inspection. This change targets master.
   
   ### Testing
   
   - Added `VersionWithTimeTest.TimestampTracksOnlyAdvances` and 
`VersionWithTimeTest.ConcurrentUpdatesAndReads` to the BE unit test target.
   - BE unit tests, regression tests, and post-fix TSan have not been run.
   
   ### Release note
   
   Fix inconsistent partition visible-version snapshots used by BE compaction.
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: No
   - Pre-submission status: Partially verified: BE build, clang-tidy, unit 
tests, regression tests, and post-fix TSan have not been run.
   
   ### AI Disclosure
   
   - Tool: Codex (GPT-6)
   - Generated: Code, tests, and change description.
   - Human review: The author reviewed the code, discussed the lock contention 
trade-off, and approved submission.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to