sql: track cursors across savepoint rollback - #174678
Conversation
Record the cursor creation boundary at each SQL savepoint. Rollback closes cursors opened after that boundary while preserving earlier cursors and their current positions, including when an initial savepoint uses the transaction-restart cleanup path. Fixes cockroachdb#173449 Release note (bug fix): ROLLBACK TO SAVEPOINT now closes cursors opened after the savepoint and preserves cursors opened before it.
|
Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR. My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI. I have added a few people who may be able to assist in reviewing:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Root causeSQL cursor ownership is kept in That omission produced two opposite results depending on the KV savepoint state:
The query plans on the good and bad cases are the same; the first divergence is cursor lifecycle state at savepoint rollback, not query planning or row execution. FixEach SQL savepoint now records
For an initial savepoint, the scoped cleanup has already established the correct cursor set before Cursors opened before the savepoint are deliberately left as the same iterator objects, so their positions are not rewound. Cursors opened after the savepoint, including holdable cursors, are closed. Regression coverageThe new
The regression passes in all 13 default logic-test configurations. The complete local and local-read-committed cursor suites, focused savepoint/retry/cursor tests, and all 16 shards of |
Fixes #173449.
SQL savepoints currently do not track cursor lifecycle state. This change records a cursor creation boundary on each SQL savepoint, closes cursors created after that boundary when it is rolled back, and preserves earlier cursors during the transaction restart used for an initial savepoint.
Tests:
Release note (bug fix): ROLLBACK TO SAVEPOINT now closes cursors opened after the savepoint and preserves cursors opened before it.