Skip to content

sql: pin read sequence number while draining a WITH HOLD cursor for persistence - #172836

Open
sijie-Z wants to merge 2 commits into
cockroachdb:masterfrom
sijie-Z:fix/with-hold-cursor-persist-read-seqnum
Open

sql: pin read sequence number while draining a WITH HOLD cursor for persistence#172836
sijie-Z wants to merge 2 commits into
cockroachdb:masterfrom
sijie-Z:fix/with-hold-cursor-persist-read-seqnum

Conversation

@sijie-Z

@sijie-Z sijie-Z commented Jul 26, 2026

Copy link
Copy Markdown

persistCursor drains the cursor via bare cursor.Next() calls during the
COMMIT phase for WITH HOLD cursors, but never brackets the iteration
with SetReadSeqNum / restore. The fetchMoveNodeBase path already does
this to preserve Postgres-style cursor sensitivity; persistCursor
omits it, so the persisted rows can be stamped with whatever the
txn's read seqnum has advanced to since DECLARE.

Apply the same pin/restore in persistCursor. Add a logictest regression.

Fixes #172772

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

…ersistence

persistCursor drains the cursor via bare cursor.Next() calls during the
COMMIT phase for WITH HOLD cursors, but never brackets the iteration
with SetReadSeqNum / restore. The fetchMoveNodeBase path already does
this to preserve Postgres-style cursor sensitivity; persistCursor
omits it, so the persisted rows can be stamped with whatever the
txn's read seqnum has advanced to since DECLARE.

Apply the same pin/restore in persistCursor. Add a logictest regression.

Fixes cockroachdb#172772

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@blathers-crl

blathers-crl Bot commented Jul 26, 2026

Copy link
Copy Markdown

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR.

Before a member of our team reviews your PR, I have some potential action items for you:

  • Please ensure your git commit message contains a release note.
  • When CI has completed, please ensure no errors have appeared.

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.

@blathers-crl blathers-crl Bot added O-community Originated from the community X-blathers-triaged blathers was able to find an owner labels Jul 26, 2026
@blathers-crl
blathers-crl Bot requested a review from DrewKimball July 26, 2026 16:35
Verify that a cursor persisted at COMMIT does not observe writes
performed after DECLARE. Without the fix in the previous commit,
FETCH ALL returns row 100 alongside 1..11; with the fix, only
the DECLARE-time snapshot (rows 1..11) is returned.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@blathers-crl

blathers-crl Bot commented Jul 26, 2026

Copy link
Copy Markdown

Thank you for updating your pull request.

Before a member of our team reviews your PR, I have some potential action items for you:

  • We notice you have more than one commit in your PR. We try break logical changes into separate commits, but commits such as "fix typo" or "address review commits" should be squashed into one commit and pushed with --force
  • Please ensure your git commit message contains a release note.
  • When CI has completed, please ensure no errors have appeared.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-community Originated from the community X-blathers-triaged blathers was able to find an owner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: WITH HOLD cursor persisted at COMMIT can observe writes performed after DECLARE

1 participant