Skip to content

fix(leader): fix the concurrent write causes disordered offset#738

Merged
mattisonchao merged 3 commits intomainfrom
fix.concurrent.write
Aug 12, 2025
Merged

fix(leader): fix the concurrent write causes disordered offset#738
mattisonchao merged 3 commits intomainfrom
fix.concurrent.write

Conversation

@mattisonchao
Copy link
Copy Markdown
Member

@mattisonchao mattisonchao commented Aug 12, 2025

Motivation

#668 introduced a regression that made concurrent writes fail.

This comment was marked as outdated.

@mattisonchao mattisonchao requested a review from Copilot August 12, 2025 06:55

This comment was marked as outdated.

@mattisonchao mattisonchao requested a review from Copilot August 12, 2025 07:01
Copy link
Copy Markdown
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 concurrency bug in the leader controller where concurrent writes could result in disordered offsets, addressing a regression introduced by issue #668.

  • Moves the mutex unlock operation after the WAL append operation to ensure proper synchronization
  • Refactors the WAL append callback to be defined before the append call for better code organization
  • Adds a comprehensive test case to verify concurrent write operations work correctly

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
server/leader_controller.go Fixes the concurrent write issue by properly ordering mutex unlock and WAL append operations
server/leader_controller_test.go Adds test coverage for concurrent write scenarios to prevent regression

@mattisonchao mattisonchao merged commit aa77dc4 into main Aug 12, 2025
8 checks passed
@mattisonchao mattisonchao deleted the fix.concurrent.write branch August 12, 2025 11:06
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