Skip to content

Commit 97b0bf1

Browse files
committed
fix: build because of false positive error
1 parent 430cb91 commit 97b0bf1

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/server/cluster/cluster_family.cc

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,26 +1006,25 @@ void ClusterFamily::DflyMigrateAck(CmdArgList args, SinkReplyBuilder* builder) {
10061006
}
10071007

10081008
void ClusterFamily::BreakStalledFlowsInShard() {
1009-
std::unique_lock global_lock(migration_mu_, std::defer_lock);
1010-
10111009
// give up on blocking because we run this function periodically in a background fiber,
10121010
// so it will eventually grab the lock.
1013-
if (!global_lock.try_lock())
1014-
return;
1015-
1016-
int64_t timeout_ns = int64_t(absl::GetFlag(FLAGS_migration_timeout)) * 1'000'000LL;
1017-
for (auto& om : outgoing_migration_jobs_) {
1018-
if (om->GetState() == MigrationState::C_FINISHED)
1019-
continue;
1020-
1021-
int64_t now = absl::GetCurrentTimeNanos();
1022-
int64_t last_write_ns = om->GetShardLastWriteTime();
1023-
1024-
if (last_write_ns > 0 && last_write_ns + timeout_ns < now) {
1025-
LOG(WARNING) << "Source node detected migration timeout for: "
1026-
<< om->GetMigrationInfo().ToString()
1027-
<< " last_write_ms: " << last_write_ns / 1000'000 << ", now: " << now / 1000'000;
1028-
om->Finish(true, "Detected migration timeout");
1011+
if (migration_mu_.try_lock()) {
1012+
std::lock_guard lock(migration_mu_, std::adopt_lock);
1013+
int64_t timeout_ns = int64_t(absl::GetFlag(FLAGS_migration_timeout)) * 1'000'000LL;
1014+
for (auto& om : outgoing_migration_jobs_) {
1015+
if (om->GetState() == MigrationState::C_FINISHED)
1016+
continue;
1017+
1018+
int64_t now = absl::GetCurrentTimeNanos();
1019+
int64_t last_write_ns = om->GetShardLastWriteTime();
1020+
1021+
if (last_write_ns > 0 && last_write_ns + timeout_ns < now) {
1022+
LOG(WARNING) << "Source node detected migration timeout for: "
1023+
<< om->GetMigrationInfo().ToString()
1024+
<< " last_write_ms: " << last_write_ns / 1000'000
1025+
<< ", now: " << now / 1000'000;
1026+
om->Finish(true, "Detected migration timeout");
1027+
}
10291028
}
10301029
}
10311030
}

src/server/cluster/cluster_family.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ClusterFamily {
4646

4747
// Tries to break those flows for migration outgoing migrations that stuck on socket write for too
4848
// long time.
49-
void BreakStalledFlowsInShard();
49+
void BreakStalledFlowsInShard() ABSL_NO_THREAD_SAFETY_ANALYSIS;
5050

5151
// Only for debug purpose. Pause/Resume all incoming migrations
5252
void PauseAllIncomingMigrations(bool pause);

0 commit comments

Comments
 (0)