Skip to content

log: support discard action on write timeout#48

Open
bb7133 wants to merge 1 commit into
masterfrom
bb7133/log-timeout-action
Open

log: support discard action on write timeout#48
bb7133 wants to merge 1 commit into
masterfrom
bb7133/log-timeout-action

Conversation

@bb7133

@bb7133 bb7133 commented Jun 4, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Config.Timeout currently always panics when a log write/sync waits too long for the writer lock. TiDB needs a configurable behavior so operators can choose to discard subsequent logs instead of panicking when log I/O is stuck.

What changed and how does it work?

  • Add Config.TimeoutAction with valid actions panic and discard. Empty action keeps the existing panic behavior.
  • Keep LockWithTimeout as the panic-compatible wrapper.
  • Add LockWithTimeoutAction for callers that want discard behavior.
  • In discard mode, timed-out Write returns len(bs), nil and timed-out Sync returns nil. After the first timeout, subsequent calls discard immediately while the writer lock is still unavailable, instead of waiting the full timeout repeatedly.

Check List

Tests

  • Unit test
go test ./...

@YangKeao YangKeao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

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.

3 participants