hbswcsyzx opened a new pull request, #1884:
URL: https://github.com/apache/cloudberry/pull/1884

   Fixes #1465
   
   ### What does this PR do?
   
   Fixes a distributed snapshot visibility race during distributed transaction
   commit. The coordinator now removes the distributed GXID from the proc array
   before dispatching the QE commit notification. This prevents a concurrent
   distributed snapshot from retaining a GXID after the QEs have committed the
   transaction and incorrectly selecting the old tuple version.
   
   The change retains the GXID/GID locally after proc-array cleanup so commit
   retry, abort handling, diagnostics, and the `FORGET COMMITTED` record 
continue
   to use the correct transaction identifier. The same ordering is applied to
   the one-phase commit notification path.
   
   ### Type of Change
   
   - [x] Bug fix (non-breaking change)
   - [ ] New feature (non-breaking change)
   - [ ] Breaking change (fix or feature with breaking changes)
   - [ ] Documentation update
   
   ### Test Plan
   
   - [ ] Unit tests added/updated
   - [x] Integration tests added/updated
   - [ ] Passed `make installcheck`
   - [ ] Passed `make -C src/test installcheck-cbdb-parallel`
   
   Targeted validation for issue #1465 was performed in a fresh Docker cluster
   built from this branch:
   
   - The new isolation test reproduces the commit/proc-array race with fault
     injection and passes with zero `gpdiff` output.
   - The unpatched baseline deterministically returns the stale value; the fixed
     build returns the committed value in both snapshot reads.
   - `dtm_retry.sql` completes ten `COMMIT PREPARED` retries with a non-zero 
GID,
     and its abort-some-prepared and abort-prepared checks pass.
   - One-phase commit success and injected QE failure/rollback paths pass.
   - A 120-second targeted workload with 16 writers and 8 repeatable-read
     readers completes successfully. The writers commit 6,692 transactions, the
     final table sum is 6,692 with 1,000 rows, 46,207 reader transactions pass
     their row-count assertions, and no prepared transactions remain.
   - The final Docker cluster logs contain no `PANIC`, `FATAL`, or assertion
     failure.
   
   ### Impact
   
   **Performance:**
   
   No additional network round trips are introduced. The coordinator performs
   the existing proc-array cleanup before commit notification and retains the
   transaction identifier locally for the remainder of the commit path.
   
   **User-facing changes:**
   
   This corrects snapshot visibility for concurrently committed distributed
   updates. There are no syntax, catalog, or API changes.
   
   **Dependencies:**
   
   None.
   
   ### Checklist
   
   - [x] Followed [contribution 
guide](https://cloudberry.apache.org/contribute/code)
   - [ ] Added/updated documentation
   - [x] Reviewed code for security implications
   - [ ] Requested review from [cloudberry 
committers](https://github.com/orgs/apache/teams/cloudberry-committers)
   
   ### Additional Context
   
   The fix is contained in `src/backend/cdb/cdbtm.c` and
   `src/include/cdb/cdbtm.h`. The regression test is registered in the 
isolation2
   schedule at `src/test/isolation2/isolation2_schedule`.
   
   The local Docker reproduction harness used for validation is intentionally 
not
   part of this PR.


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