-
Notifications
You must be signed in to change notification settings - Fork 609
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
[CORE-7058]: storage
: fix race condition in segment::release_appender_in_background()
#24483
Merged
dotnwat
merged 4 commits into
redpanda-data:dev
from
WillemKauf:segment_appender_race_fix
Dec 13, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
edc0ab3
`storage`: fix race condition in `segment::release_appender_in_backgr…
WillemKauf 7a29f24
`storage`: use `model::next_offset()` in `segment::force_roll()`
WillemKauf c0d76d1
`storage`: move `storage_e2e_fixture` to its own header file
WillemKauf 24ec834
`storage`: add `test_concurrent_segment_roll_and_close`
WillemKauf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2024 Redpanda Data, Inc. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.md | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0 | ||
|
||
#include "redpanda/tests/fixture.h" | ||
#include "storage/disk_log_impl.h" | ||
#include "storage/segment.h" | ||
#include "test_utils/scoped_config.h" | ||
|
||
#include <seastar/core/future.hh> | ||
#include <seastar/core/shared_ptr.hh> | ||
|
||
struct storage_e2e_fixture : public redpanda_thread_fixture { | ||
scoped_config test_local_cfg; | ||
|
||
// Produces to the given fixture's partition for 10 seconds. | ||
ss::future<> produce_to_fixture(model::topic topic_name, int* incomplete) { | ||
tests::kafka_produce_transport producer(co_await make_kafka_client()); | ||
co_await producer.start(); | ||
const int cardinality = 10; | ||
auto now = ss::lowres_clock::now(); | ||
while (ss::lowres_clock::now() < now + 5s) { | ||
for (int i = 0; i < cardinality; i++) { | ||
co_await producer.produce_to_partition( | ||
topic_name, | ||
model::partition_id(0), | ||
tests::kv_t::sequence(i, 1)); | ||
} | ||
} | ||
*incomplete -= 1; | ||
} | ||
|
||
ss::future<> remove_segment_permanently( | ||
storage::disk_log_impl* log, ss::lw_shared_ptr<storage::segment> seg) { | ||
return log->remove_segment_permanently(seg, "storage_e2e_fixture") | ||
.then([&, log, seg]() { | ||
auto& segs = log->segments(); | ||
auto it = std::find(segs.begin(), segs.end(), seg); | ||
if (it == segs.end()) { | ||
return; | ||
} | ||
segs.erase(it, std::next(it)); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is this related to the race?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to the race, related to the test case I wrote in which I call
force_roll()
on a log that has nothing produced to it,offsets.dirty_offset() == -9223372036854775808
, and the offset value-9223372036854775808 + 1
is going to trigger an assert indisk_log_impl::new_segment()
.If, instead, we use
model::next_offset(-9223372036854775808) == 0
, we are okay 👍There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, got it. i forgot that force_roll is test-only code. yolo!