Susuper2019 opened a new pull request, #70960: URL: https://github.com/apache/doris/pull/70960
### Background Flexible partial updates on a Unique Key merge-on-write table read the previous row to fill columns omitted from the incoming write. A primary key index can still point to a physical row that the tablet delete bitmap has made invisible. ### What problem does this PR solve? Issue Number: #70873 Related PR: See the timeline of #70873 for related work. PR Type: Bugfix Problem Summary: A concurrent update can inherit a stale sequence and column values from a hidden row. Two versions of the same key can then be visible before compaction, and compaction can discard the version containing the new column values. This patch makes the shared lookup check visibility before returning a sequence conflict. ### Details - **Frequency:** Reproduced with concurrent flexible partial updates when a newer rowset contains a bitmap-deleted match with a higher sequence than the prepared key. - **Root cause:** Tablet lookup checked the delete bitmap only on an OK status. A segment returning KEY_ALREADY_EXISTS bypassed the check and could stop the search before an older visible rowset was reached. - **Why existing tests missed it:** A conflict with a visible row correctly returns KEY_ALREADY_EXISTS. That status alone cannot distinguish returning the hidden rowset from returning the visible one. - **Fix:** Check the candidate's visibility for both match statuses. Decode the physical row ID before returning a sequence conflict on cluster-key tables so the bitmap lookup addresses the correct row. - **Other paths and branches:** The shared BE lookup still rejects an explicitly lower sequence against a visible higher-sequence row. Tested on master at 1346aef6. - **Behavior change:** Partial updates inherit missing values from a visible prior row. ### Testing - Built the native FE and BE on macOS arm64. Ran a focused ASAN GTest binary linked against the actual BE libraries with the upstream test entry point and KeyProbeTest.*. With the parent revision's storage code, 13 passed and both new tests failed: lookup returned hidden rowset 4102 instead of visible rowset 4101, and a cluster-key sequence conflict reported primary-key ordinal 0 instead of physical row ID 1. With the patch, all 15 passed. - Replayed the four Stream Load 2PC transactions from #70873 twice, including with the final packaged binary, on a local one-FE, three-BE cluster using the patched BE. Queried the same key on each replica at each checkpoint: | Checkpoint | Visible rows per replica | Row (id, color, note, seq) | | --- | --- | --- | | Explicit seq=10 commits after seq=20 | 1 | (1, NULL, NULL, 20) | | Color update becomes visible | 1 | (1, blue, NULL, 20) | | Note update becomes visible, before compaction | 1 | (1, blue, sample, 20) | | First cumulative compaction covering the final write on each BE | 1 | (1, blue, sample, 20) | Using the same write order on a fresh three-BE cluster, we also varied when each replica compacted. Two replicas compacted the low-sequence row before the prepared partial update published. The third compacted later. After compaction the parent returned row counts of 0, 1, 1 across replicas. The patched build returned one complete row with sequence 20 on every replica. ### Release note Fix incorrect column values and duplicate visible keys caused by inheriting from a bitmap-deleted row during concurrent partial updates with a sequence column. ### Check List (For Author) - Behavior changed: Yes (see Details). - Does this need documentation: No. - Pre-submission status: Ready. ### AI Disclosure - Tool: OpenAI Codex. - Generated: Code, tests, description, and local verification. - Human review: Pending author review before 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]
