Skip to content

Conversation

@blathers-crl
Copy link

@blathers-crl blathers-crl bot commented Jan 5, 2026

Backport 1/1 commits from #160346 on behalf of @jeffswenson.


The conn executor creates transactions with "stepped" read sequences. The purpose of this behavior is to prevent a statement from reading its own writes, which is required by postgres semantics. When a savepoint is rolled back, it creates a [start_savepoint_seq, end_savepoint_seq) span of reverted sequences. The txn middleware validates the transaction's read sequence number to ensure it's not inside a reverted span. If the read sequence is inside a reverted span, the transaction requests return assertion failures and are not sent to the KV layer.

This validation means that if a transaction has its read timestamp inside a reverted span when it attempts to roll back the transaction, the RPCs to clean up the transaction are never sent. The transaction is orphaned and is cleaned up automatically, but it leaves the locks in place for a few seconds. Since the txn is cleaned up eventually, the conn executor logs an error instead of poisoning the session.

Fixes: #156507
Fixes: #135118
Fixes: #159594
Release note (bug fix): Fixed a bug that caused rolling back a transaction that just rolled back a savepoint to block transactions touching the same rows for five seconds.


Release justification: Fixes a bug that has been escalated by customers and causes difficult to track down performance issues.

The conn executor creates transactions with "stepped" read sequences.
The purpose of this behavior is to prevent a statement from reading its
own writes, which is required by postgres semantics. When a savepoint is
rolled back, it creates a [start_savepoint_seq, end_savepoint_seq) span
of reverted sequences. The txn middleware validates the transaction's
read sequence number to ensure it's not inside a reverted span. If the
read sequence is inside a reverted span, the transaction requests return
assertion failures and are not sent to the KV layer.

This validation means that if a transaction has its read timestamp
inside a reverted span when it attempts to roll back the transaction,
the RPCs to clean up the transaction are never sent. The transaction is
orphaned and is cleaned up automatically, but it leaves the locks in
place for a few seconds. Since the txn is cleaned up eventually, the
conn executor logs an error instead of poisoning the session.

Fixes: #135118
Fixes: #159594
Release note (bug fix): Fixed a bug that caused rolling back a transaction that
just rolled back a savepoint to block transactions touching the same
rows for five seconds.
@blathers-crl blathers-crl bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels Jan 5, 2026
@blathers-crl blathers-crl bot requested review from a team, jeffswenson, rafiss and yuzefovich January 5, 2026 18:25
@blathers-crl
Copy link
Author

blathers-crl bot commented Jan 5, 2026

Thanks for opening a backport.

Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate.

@blathers-crl blathers-crl bot added backport Label PR's that are backports to older release branches T-sql-queries SQL Queries Team labels Jan 5, 2026
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@jeffswenson jeffswenson requested a review from michae2 January 5, 2026 18:26
Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@michae2 reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @jeffswenson, @rafiss, and @yuzefovich).

@jeffswenson jeffswenson merged commit a43f62d into release-25.4 Jan 7, 2026
16 checks passed
@jeffswenson jeffswenson deleted the blathers/backport-release-25.4-160346 branch January 7, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Label PR's that are backports to older release branches blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. T-sql-queries SQL Queries Team target-release-25.4.4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants