From e68977a7bfd9698792f4fe7057fde7eec82faf9c Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Wed, 26 Jan 2022 22:11:35 +0200 Subject: [PATCH] Fix Populate bug --- server/debugcmd.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/debugcmd.cc b/server/debugcmd.cc index 4cf6984..06bdeb8 100644 --- a/server/debugcmd.cc +++ b/server/debugcmd.cc @@ -106,8 +106,11 @@ void DebugCmd::Populate(CmdArgList args) { vector fb_arr(ranges.size()); for (size_t i = 0; i < ranges.size(); ++i) { - fb_arr[i] = ess_->pool()->at(i)->LaunchFiber([&] { - this->PopulateRangeFiber(ranges[i].first, ranges[i].second, prefix, val_size); + auto range = ranges[i]; + + // whatever we do, we should not capture i by reference. + fb_arr[i] = ess_->pool()->at(i)->LaunchFiber([=] { + this->PopulateRangeFiber(range.first, range.second, prefix, val_size); }); } for (auto& fb : fb_arr) @@ -119,10 +122,11 @@ void DebugCmd::Populate(CmdArgList args) { void DebugCmd::PopulateRangeFiber(uint64_t from, uint64_t len, std::string_view prefix, unsigned value_len) { this_fiber::properties().set_name("populate_range"); + VLOG(1) << "PopulateRange: " << from << "-" << (from + len - 1); string key = absl::StrCat(prefix, ":"); size_t prefsize = key.size(); - DbIndex db_indx = 0; // TODO + DbIndex db_indx = cntx_->db_index(); std::vector ps(ess_->size(), PopulateBatch{db_indx}); SetCmd::SetParams params{db_indx};