Skip to content

Fix timestamp overflow in lock cleanup causing permanent lock leaks#314

Merged
bootjp merged 7 commits intofeature/multi-shard-transactionfrom
copilot/sub-pr-313
Feb 16, 2026
Merged

Fix timestamp overflow in lock cleanup causing permanent lock leaks#314
bootjp merged 7 commits intofeature/multi-shard-transactionfrom
copilot/sub-pr-313

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

  • Replace cleanupTS with abortTSFrom to handle timestamp overflow
  • Add overflow checks where cleanupTS is called
  • Use commitTS parameter where available for consistency
  • Add clarifying comments
  • Run tests to validate the fix
  • Run code review (addressed all actionable feedback)
  • Run CodeQL security scan (no issues found)
  • Fix golangci-lint formatting issues
  • Add defensive programming comments explaining overflow handling

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits February 16, 2026 21:25
Replace cleanupTS with abortTSFrom to handle overflow when startTS==^uint64(0).
Add explicit overflow checks to prevent invalid abort timestamps that violate
the FSM requirement that resolveTS > startTS, which could leave locks permanently
unresolved.

Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com>
Pass commitTS from primaryTxnStatus to abortTSFrom for semantic clarity
and consistency with usage elsewhere in the codebase.

Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com>
Explain why startTS is passed twice to abortTSFrom: no commitTS is available
when aborting an expired lock with no commit record.

Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com>
Use 0 instead of startTS as the second parameter to abortTSFrom to explicitly
indicate that no commitTS is available in this context.

Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com>
Copilot AI changed the title [WIP] Update transaction timestamp management based on review feedback Fix timestamp overflow in lock cleanup causing permanent lock leaks Feb 16, 2026
Copilot AI requested a review from bootjp February 16, 2026 21:34
@bootjp
Copy link
Owner

bootjp commented Feb 16, 2026

@copilot golangci落ちています

@bootjp
Copy link
Owner

bootjp commented Feb 16, 2026

@copilot Uint64なので通常オーバーフローが起きない想定だが、バグで起きることを考慮したロジックであることをコメントに書いてください

Remove extra blank lines left after deleting cleanupTS function to fix
golangci-lint gci formatting check.

Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 16, 2026

@copilot golangci落ちています

Fixed in commit 3ff3e3b. Removed extra blank lines that were causing the gci formatting check to fail. golangci-lint now passes with 0 issues.

Clarify that while uint64 overflow is not expected in normal operation,
the overflow checks are defensive programming to handle the edge case
where startTS==^uint64(0) or a bug causes overflow, preventing violation
of the FSM invariant resolveTS > startTS.

Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 16, 2026

@copilot Uint64なので通常オーバーフローが起きない想定だが、バグで起きることを考慮したロジックであることをコメントに書いてください

Fixed in commit a3477b6. Added defensive programming comments at all three overflow check locations, explaining that while uint64 overflow is not expected in normal operation, these checks handle the edge case where startTS==^uint64(0) or a bug causes overflow, preventing violation of the FSM invariant.

@bootjp bootjp marked this pull request as ready for review February 16, 2026 21:43
Copilot AI review requested due to automatic review settings February 16, 2026 21:43
@bootjp bootjp merged commit 32dc5ef into feature/multi-shard-transaction Feb 16, 2026
8 checks passed
@bootjp bootjp deleted the copilot/sub-pr-313 branch February 16, 2026 21:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug where timestamp overflow during lock cleanup could cause permanent lock leaks. The fix replaces the cleanupTS function with abortTSFrom, which properly handles edge cases where incrementing timestamps would overflow (e.g., when startTS == ^uint64(0)). The new implementation returns 0 when no valid abort timestamp can be computed, and all three call sites add defensive checks to prevent violating the FSM invariant that requires resolveTS > startTS.

Changes:

  • Replaced cleanupTS with abortTSFrom for computing abort timestamps with overflow safety
  • Added overflow checks at three critical lock resolution points to prevent FSM invariant violations
  • Removed the obsolete cleanupTS function that lacked overflow handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants