Skip to content

Commit 6925b6d

Browse files
committed
Pull helio again, fix heartbeat
1 parent adf5074 commit 6925b6d

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

src/server/engine_shard.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ ABSL_FLAG(double, eviction_memory_budget_threshold, 0.1,
6868
"Eviction starts when the free memory (including RSS memory) drops below "
6969
"eviction_memory_budget_threshold * max_memory_limit.");
7070

71+
ABSL_FLAG(bool, background_heartbeat, false, "Whether to run heartbeat as a background fiber");
72+
7173
ABSL_DECLARE_FLAG(uint32_t, max_eviction_per_heartbeat);
7274

7375
namespace dfly {
@@ -535,10 +537,12 @@ void EngineShard::StartPeriodicHeartbeatFiber(util::ProactorBase* pb) {
535537
return;
536538
}
537539
auto heartbeat = [this]() { Heartbeat(); };
540+
auto priority = absl::GetFlag(FLAGS_background_heartbeat) ? fb2::FiberPriority::BACKGROUND
541+
: fb2::FiberPriority::NORMAL;
538542

539543
std::chrono::milliseconds period_ms(*cycle_ms);
540544

541-
fb2::Fiber::Opts fb_opts{.name = "heatbeat"};
545+
fb2::Fiber::Opts fb_opts{.priority = priority, .name = "heatbeat"};
542546
fiber_heartbeat_periodic_ =
543547
fb2::Fiber(fb_opts, [this, index = pb->GetPoolIndex(), period_ms, heartbeat]() mutable {
544548
ThisFiber::SetName(absl::StrCat("heartbeat_periodic", index));

src/server/snapshot.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
#include "util/fibers/synchronization.h"
2222

2323
ABSL_FLAG(bool, point_in_time_snapshot, true, "If true replication uses point in time snapshoting");
24-
ABSL_FLAG(bool, background_snapshotting, false,
25-
"If true, snapshotting uses background priority fibers");
24+
ABSL_FLAG(bool, background_snapshotting, false, "Whether to run snapshot as a background fiber");
2625

2726
namespace dfly {
2827

tests/dragonfly/instance.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ def __init__(self, params: DflyParams, args):
126126
self.args["num_shards"] = threads - 1
127127

128128
def __del__(self):
129+
if self.proc:
130+
self.stop()
129131
assert self.proc == None
130132

131133
def client(self, *args, **kwargs) -> RedisClient:
@@ -461,7 +463,11 @@ async def stop_all(self):
461463
"""Stop all launched instances."""
462464
exceptions = [] # To collect exceptions
463465
for instance in self.instances:
464-
await instance.close_clients()
466+
try: # ioloop might be no longer running
467+
await instance.close_clients()
468+
except Exception as e:
469+
pass
470+
465471
try:
466472
instance.stop()
467473
except Exception as e:

tests/dragonfly/replication_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ async def test_replication_all(
7171
args["maxmemory"] = str(t_master * 256) + "mb"
7272

7373
if background_snapshotting:
74+
args["background_heatbeat"] = None
7475
args["background_snapshotting"] = None
7576

7677
master = df_factory.create(

0 commit comments

Comments
 (0)