Commit 6315105
authored
fix(spanner): guard rollback when aborted commit cleared session handle (#14218)
Fixes: #14025
Fix a panic in `ReadWriteTransaction.rollback` when a statement-based
transaction commit is aborted, commit cleanup clears `t.sh`, and a later
rollback is triggered after retry reset fails.
## Root cause
`ReadWriteStmtBasedTransaction.CommitWithReturnResp` recycles the
session handle and sets `t.sh = nil` even when commit returns `ABORTED`.
If a caller then tries to retry with a canceled context, `ResetForRetry`
fails before a new transaction is created.
Cleanup paths can still call `Rollback` on the original transaction.
`ReadWriteTransaction.rollback` dereferenced
`t.sh` without checking whether the handle itself was nil, which caused
a panic.
## Change
- Snapshot `t.sh` inside `ReadWriteTransaction.rollback`
- Return early if the session handle is nil
- Use the local snapshot for `getID`, `getClient`, and `getMetadata`
This keeps rollback a no-op when the session handle has already been
cleaned up, which matches the intended behavior for an already-aborted
transaction.1 parent 48c70e2 commit 6315105
2 files changed
+57
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1932 | 1932 | | |
1933 | 1933 | | |
1934 | 1934 | | |
| 1935 | + | |
1935 | 1936 | | |
1936 | 1937 | | |
1937 | 1938 | | |
1938 | | - | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
1939 | 1943 | | |
1940 | 1944 | | |
1941 | 1945 | | |
1942 | | - | |
| 1946 | + | |
1943 | 1947 | | |
1944 | 1948 | | |
1945 | 1949 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
728 | 728 | | |
729 | 729 | | |
730 | 730 | | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
731 | 782 | | |
732 | 783 | | |
733 | 784 | | |
| |||
0 commit comments