Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stm_manager: tighten interaction between bg application and snapshots #18576

Merged
merged 2 commits into from
Jul 5, 2024

Conversation

bharathv
Copy link
Contributor

@bharathv bharathv commented May 20, 2024

wait for background applicators to finish before applying raft
snapshots, else there is a danger of next_to_apply offset moving
backwards with interleaved bg_apply and snapshot fibers.

Fixes #18415

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v24.1.x
  • v23.3.x
  • v23.2.x

Release Notes

Bug Fixes

  • Fixed a crash during raft snapshot application (prefix truncation of the log). A race condition between raft snapshot application and lagging state machine apply fibers caused the state machine offset to move backwards incorrectly.

@bharathv
Copy link
Contributor Author

bharathv commented Jul 1, 2024

umm, looks like the assert is still firing, I'll have to take another look.

wait for background applicators to finish before applying raft
snapshots, else there is a danger of next_to_apply offset moving
backwards with interleaved bg_apply and snapshot fibers.
@bharathv
Copy link
Contributor Author

bharathv commented Jul 4, 2024

/ci-repeat 1

@vbotbuildovich
Copy link
Collaborator

skipped ducktape retry in https://buildkite.com/redpanda/redpanda/builds/51118#01908002-10a7-4a12-b098-2a98ca78ea56:
pandatriage cache was not found

@piyushredpanda piyushredpanda merged commit 6a57782 into redpanda-data:dev Jul 5, 2024
15 of 18 checks passed
@vbotbuildovich
Copy link
Collaborator

/backport v24.1.x

@vbotbuildovich
Copy link
Collaborator

/backport v23.3.x

@@ -276,6 +281,7 @@ ss::future<> state_machine_manager::do_apply_raft_snapshot(
});
}
_next = model::next_offset(metadata.last_included_index);
background_apply_units.clear();
Copy link
Member

Choose a reason for hiding this comment

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

what's the reason for clearing the units here compared to making acquire_background_apply_mutexes be RAII (e.g. with_background_apply_mutexes(...?

Copy link
Contributor Author

@bharathv bharathv Jul 9, 2024

Choose a reason for hiding this comment

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

Just wanted to make it explicit to the reader..

I wanted to do this.

ss::future<> state_machine_manager::do_apply_raft_snapshot(
  snapshot_metadata metadata,
  storage::snapshot_reader& reader,
  std::vector<ssx::semaphore_units> background_apply_units) {

over

ss::future<> state_machine_manager::do_apply_raft_snapshot(
  snapshot_metadata metadata,
  storage::snapshot_reader& reader,
  std::vector<ssx::semaphore_units>) {

that signifies these units are from bg_applicators but the former won't compile because background_apply_units remains unused, so I had to use it some how, so explicitly cleared the vector.

I guess I could've used [[maybe_unused]]

@BenPope
Copy link
Member

BenPope commented Jul 17, 2024

@bharathv I think the release note could add a little context: https://github.com/redpanda-data/redpanda/releases/tag/untagged-e8ce2cd9a5a987a31e3f

@bharathv
Copy link
Contributor Author

@bharathv I think the release note could add a little context: https://github.com/redpanda-data/redpanda/releases/tag/untagged-e8ce2cd9a5a987a31e3f

Done.

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

Successfully merging this pull request may close these issues.

CI Failure (can not move next offset backward) in RandomNodeOperationsTest.test_node_operations
6 participants