multishard_mutation_query: read_context: save_reader: destroy reader_meta from the calling shard
The reader_meta in _readers[shard] is created on shard 0 and must be destroyed on it as well. A following patch changes next_partition() to return a future<> thus it introduces a continuation that requires access to `rm`. We cannot move it down to the conuation safely, since it will be wrongly destroyed in the invoked shard, so use do_with to hold it in the scope of the calling shard until the invoked function completes. Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
@@ -457,7 +457,8 @@ read_context::dismantle_buffer_stats read_context::dismantle_compaction_state(de
|
||||
}
|
||||
|
||||
future<> read_context::save_reader(shard_id shard, const dht::decorated_key& last_pkey, const std::optional<clustering_key_prefix>& last_ckey) {
|
||||
return _db.invoke_on(shard, [this, shard, query_uuid = _cmd.query_uuid, query_ranges = _ranges, rm = std::exchange(_readers[shard], {}),
|
||||
return do_with(std::exchange(_readers[shard], {}), [this, shard, &last_pkey, &last_ckey] (reader_meta& rm) mutable {
|
||||
return _db.invoke_on(shard, [this, query_uuid = _cmd.query_uuid, query_ranges = _ranges, &rm,
|
||||
&last_pkey, &last_ckey, gts = tracing::global_trace_state_ptr(_trace_state)] (database& db) mutable {
|
||||
try {
|
||||
flat_mutation_reader_opt reader = try_resume(rm.rparts->permit.semaphore(), std::move(*rm.handle));
|
||||
@@ -511,6 +512,7 @@ future<> read_context::save_reader(shard_id shard, const dht::decorated_key& las
|
||||
// know where exactly the failure happened anyway.
|
||||
++_db.local().get_stats().multishard_query_failed_reader_saves;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
future<> read_context::lookup_readers() {
|
||||
|
||||
Reference in New Issue
Block a user