@@ -156,3 +156,31 @@ FIXTURE_TEST(test_concurrent_log_eviction_and_append, storage_e2e_fixture) {
156
156
// final round of eviction.
157
157
BOOST_REQUIRE_LE (log ->segment_count (), 1 );
158
158
}
159
+
160
+ FIXTURE_TEST (test_concurrent_segment_roll_and_close, storage_e2e_fixture) {
161
+ const auto topic_name = model::topic (" tapioca" );
162
+ const auto ntp = model::ntp (model::kafka_namespace, topic_name, 0 );
163
+
164
+ cluster::topic_properties props;
165
+ add_topic ({model::kafka_namespace, topic_name}, 1 , props).get ();
166
+ wait_for_leader (ntp).get ();
167
+
168
+ auto partition = app.partition_manager .local ().get (ntp);
169
+ auto * log = dynamic_cast <storage::disk_log_impl*>(partition->log ().get ());
170
+ auto seg = log ->segments ().back ();
171
+
172
+ // Hold a read lock, which will force release_appender() to go through
173
+ // release_appender_in_background()
174
+ auto read_lock_holder = seg->read_lock ().get ();
175
+
176
+ auto roll_fut = log ->force_roll (ss::default_priority_class ());
177
+ auto release_holder_fut = ss::sleep (100ms).then (
178
+ [read_locker_holder = std::move (read_lock_holder)] {});
179
+ auto remove_segment_fut = remove_segment_permanently (log , seg);
180
+
181
+ ss::when_all (
182
+ std::move (roll_fut),
183
+ std::move (remove_segment_fut),
184
+ std::move (release_holder_fut))
185
+ .get ();
186
+ }
0 commit comments