Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

uv_append: Don't finalize segment if there are writes in-flight #265

Merged
merged 1 commit into from
Feb 15, 2022

Conversation

MathieuBordere
Copy link
Contributor

@MathieuBordere MathieuBordere commented Feb 15, 2022

calling uvAliveSegmentFinalize(s) while there are writes against the alive segment in flight could lead to uvWriterClose being called twice, leading to a triggered assertion src/uv_writer.c:393: UvWriterClose: Assertion '!w->closing' failed.

This can happen when e.g.:

  • write against open segment completes in uvAliveSegmentWriteCb
  • write triggers a checkpoint
  • checkpoint triggers a raft apply command
  • triggers a write against the open segment
  • adds write to poll_queue
  • raft apply command triggers a snapshot
  • snapshot triggers finalization of open segment
  • causes uvAliveSegmentFinalize(s) to be called here
  • leading to the cancellation of requests in the poll_queue
  • leading to a failed write and UvWriterClose being called again.

To avoid this, no longer finalize the alive segment if there is a write in-flight, checked by comparing pending_last_index & last_index on the segment. When the in-flight write completes, the segment will be finalized.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants