Skip to content

transaction: add contextual logging with start_ts (#267)#548

Merged
ti-chi-bot[bot] merged 2 commits into
tikv:masterfrom
getwyrd:feat/logging-267
Jul 11, 2026
Merged

transaction: add contextual logging with start_ts (#267)#548
ti-chi-bot[bot] merged 2 commits into
tikv:masterfrom
getwyrd:feat/logging-267

Conversation

@eduralph

@eduralph eduralph commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Enrich the transaction lifecycle, plan/retry, and region-cache logging with each transaction's start_ts and region/store context; add commit/rollback outcome logs, log dropping an active transaction under all check levels, and a terminal warn when region-error retries are exhausted. Truncate keys in the one full-key error log. Fix message typos/duplicates and remove dead logger-threading comments. Add a dependency-free capture-logger test and a RUST_LOG note to the README.

Refs #267

Signed-off-by: Eduard Ralph eduard@ralphovi.net

Summary by CodeRabbit

  • Documentation
    • Added a new Logging section covering how logging is handled, how to choose a backend, RUST_LOG, and how log levels correspond to transaction lifecycle and operational/error events.
  • Bug Fixes
    • Fixed misleading debug output for reverse key scans.
  • Improvements
    • Expanded transaction lifecycle/2PC logging with start timestamps and more timing/lock context; refined region error, retry, and cache invalidation logs.
    • Improved logged key prefixes by hex-encoding and truncating for readability.
  • Tests
    • Added log-capture assertions to verify lifecycle logs include the transaction start timestamp.

Enrich the transaction lifecycle, plan/retry, and region-cache logging with
each transaction's start_ts and region/store context; add commit/rollback
outcome logs, log dropping an active transaction under all check levels, and a
terminal warn when region-error retries are exhausted. Truncate keys in the
one full-key error log. Fix message typos/duplicates and remove dead
logger-threading comments. Add a dependency-free capture-logger test and a
RUST_LOG note to the README.

Refs tikv#267

Signed-off-by: Eduard Ralph <eduard@ralphovi.net>
@ti-chi-bot ti-chi-bot Bot added dco-signoff: yes Indicates the PR's author has signed the dco. contribution This PR is from a community contributor. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1807e24c-7fea-498d-844d-fc2ebbc549fe

📥 Commits

Reviewing files that changed from the base of the PR and between feff589 and 56fb14c.

📒 Files selected for processing (1)
  • src/transaction/lock.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/transaction/lock.rs

📝 Walkthrough

Walkthrough

This PR expands logging across client operations, region retries, cache updates, and transaction/2PC lifecycles. It adds contextual timestamps and durations, hexadecimal key formatting, log-capture tests, and README guidance for configuring log output.

Changes

Logging improvements

Layer / File(s) Summary
Logging documentation and client operations
README.md, src/raw/client.rs, src/transaction/client.rs
Documents log configuration, fixes the reverse-scan log label, and enriches transaction client lifecycle and garbage-collection messages.
Cache and region retry logging
src/region_cache.rs, src/request/plan.rs
Adds cache update/invalidation logs and enriches region retry diagnostics with identifiers, errors, and exhausted-retry warnings.
Reusable key log formatting
src/transaction/lock.rs
Makes format_key_for_log crate-visible, formats key prefixes as hexadecimal with 16-byte truncation, and adds unit tests.
Transaction and 2PC lifecycle logging
src/transaction/transaction.rs
Adds start timestamp and operation context to transaction, heartbeat, pessimistic lock, Drop, and 2PC logs; updates commit completion details and TransactionStatus debugging.
Transaction log capture validation
src/transaction/transaction.rs
Adds a capturing logger and an asynchronous test verifying lifecycle logs include start_ts.

Estimated code review effort: 2 (Simple) | ~15 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding contextual transaction logging with start_ts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pingyu pingyu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rest LGTM.

Comment thread src/transaction/lock.rs
@ti-chi-bot ti-chi-bot Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 10, 2026
format_key_for_log printed the prefix with {:?} on a byte slice, which
renders as a decimal array (prefix=[104, 101, 108, 108, 111]). Format it
with kv::HexRepr instead so it reads as prefix=68656C6C6F, matching how
Key and KvPair already render bytes in their Debug impls.

Refs tikv#267

Signed-off-by: Eduard Ralph <eduard@ralphovi.net>
@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jul 11, 2026
@pingyu pingyu requested a review from iosmanthus July 11, 2026 14:02
@ti-chi-bot

ti-chi-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: iosmanthus, pingyu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 11, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-07-11 14:02:44.876463514 +0000 UTC m=+463150.912558570: ☑️ agreed by pingyu.
  • 2026-07-11 14:07:17.906659581 +0000 UTC m=+463423.942754627: ☑️ agreed by iosmanthus.

@ti-chi-bot ti-chi-bot Bot merged commit 1e8a488 into tikv:master Jul 11, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved contribution This PR is from a community contributor. dco-signoff: yes Indicates the PR's author has signed the dco. lgtm size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants