8000 Synchronize CAS test clock and retry callbacks by k-morozov · Pull Request #2801 · Altinity/ClickHouse · GitHub
[go: up one dir, main page]

Skip to content
8000
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class CasRequests

/// Both may be called concurrently on one `CasRequests`: neither writes a member, and the only
/// state either reads is the backend and the fence -- whose closures must therefore be thread-safe
/// too. The test setters below DO write members, and belong to setup, before any operation runs.
/// too.
///
/// Admitted now, under the fence's current generation.
CasOperation admit(Liveness liveness = {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,15 @@ PoolPtr Pool::openForDecommission(BackendPtr backend, PoolConfig config, const S
store->setEventSink(std::move(store->config.event_sink));
store->decommission_admin = true;

if (store->config.retry_sleep_fn)
{
store->ref_ledger.setRefRecoveryRetrySleepForTest(
[sleep_fn = store->config.retry_sleep_fn](uint64_t ms, const std::optional<DetachedStopToken> &)
{
sleep_fn(ms);
});
}

/// Register-before-first-write, belt-and-braces: same invariant `open` asserts.
chassert(store->isAlgoAdmitted(write_algo));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,6 @@ DecommissionReport decommissionPoolMember(BackendPtr backend, PoolConfig config,

/// The admin claim. `NoWait` refuses a live victim and accepts a tombstoned owner.
PoolPtr admin = Pool::openForDecommission(std::move(backend), std::move(config), victim_srid);
if (drain_now_fn && drain_sleep_fn)
{
admin->setCasRequestNowFnForTest(drain_now_fn);
admin->setCasRetrySleepForTest(drain_sleep_fn);
}
const UInt128 victim_uuid = admin->poolConfig().server_id;
const uint64_t admin_epoch = admin->writerEpoch();
const Layout layout = admin->layout();
Expand Down
2 changes: 1 addition & 1 deletion src/Disks/tests/gtest_cas_gc_teardown_stop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ TEST(CASGCTeardownStop, OpenPlaneSleepReturnsAtOnceOnceTeardownBegan)
store->beginTeardown();

auto paused = std::async(std::launch::async, [&store] { store->openRequests().pause(60'000); });
EXPECT_EQ(paused.wait_for(std::chrono::seconds(10)), std::future_status::ready)
ASSERT_EQ(paused.wait_for(std::chrono::seconds(10)), std::future_status::ready)
<< "the open plane's sleep must observe the arm; a plain sleep holds for the full minute";

/// Clearing the seam must put the interruptible sleep back, not the engine's plain one.
Expand Down
Loading
0