From 9dd714ae641c8a920322d2584d229ea15038bc56 Mon Sep 17 00:00:00 2001 From: Calle Wilund Date: Tue, 3 Dec 2019 16:26:06 +0000 Subject: [PATCH] commitlog_replayer: Ensure applied frozen_mutation is safe during apply Fixes #5211 In 79935df959a7066ab1a61c1c4b350391a23cc2b5 replay apply-call was changed from one with no continuation to one with. But the frozen mutation arg was still just lambda local. Change to use do_with for this case as well. Message-Id: <20191203162606.1664-1-calle@scylladb.com> (cherry picked from commit 56a5e0a2514c37571c3481de603776e0bf73a474) --- db/commitlog/commitlog_replayer.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/commitlog/commitlog_replayer.cc b/db/commitlog/commitlog_replayer.cc index 1c225f2c89..2737e38d3b 100644 --- a/db/commitlog/commitlog_replayer.cc +++ b/db/commitlog/commitlog_replayer.cc @@ -276,7 +276,7 @@ future<> db::commitlog_replayer::impl::process(stats* s, commitlog::buffer_and_r } auto shard = _db.local().shard_of(fm); - return _db.invoke_on(shard, [this, cer = std::move(cer), &src_cm, rp, shard, s] (database& db) -> future<> { + return _db.invoke_on(shard, [this, cer = std::move(cer), &src_cm, rp, shard, s] (database& db) mutable -> future<> { auto& fm = cer.mutation(); // TODO: might need better verification that the deserialized mutation // is schema compatible. My guess is that just applying the mutation @@ -306,7 +306,9 @@ future<> db::commitlog_replayer::impl::process(stats* s, commitlog::buffer_and_r return db.apply_in_memory(m, cf, db::rp_handle(), db::no_timeout); }); } else { - return db.apply_in_memory(fm, cf.schema(), db::rp_handle(), db::no_timeout); + return do_with(std::move(cer).mutation(), [&](const frozen_mutation& m) { + return db.apply_in_memory(m, cf.schema(), db::rp_handle(), db::no_timeout); + }); } }).then_wrapped([s] (future<> f) { try {