system_keyspace: De-static compaction history update
Compaction manager now has the weak reference on the system keyspace object and can use it to update its stats. It only needs to take care and keep the shared pointer until the respective future resolves. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -353,7 +353,8 @@ future<> compaction_manager::task::update_history(compaction::table_state& t, co
|
||||
// shows how many sstables each row is merged from. This information
|
||||
// cannot be accessed until we make combined_reader more generic,
|
||||
// for example, by adding a reducer method.
|
||||
co_await db::system_keyspace::update_compaction_history(cdata.compaction_uuid, t.schema()->ks_name(), t.schema()->cf_name(),
|
||||
auto sys_ks = _cm._sys_ks; // hold pointer on sys_ks
|
||||
co_await sys_ks->update_compaction_history(cdata.compaction_uuid, t.schema()->ks_name(), t.schema()->cf_name(),
|
||||
ended_at.count(), res.stats.start_size, res.stats.end_size, std::unordered_map<int32_t, int64_t>{});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2865,9 +2865,6 @@ static map_type_impl::native_type prepare_rows_merged(std::unordered_map<int32_t
|
||||
future<> system_keyspace::update_compaction_history(utils::UUID uuid, sstring ksname, sstring cfname, int64_t compacted_at, int64_t bytes_in, int64_t bytes_out,
|
||||
std::unordered_map<int32_t, int64_t> rows_merged)
|
||||
{
|
||||
if (!db::qctx) {
|
||||
return make_ready_future<>();
|
||||
}
|
||||
// don't write anything when the history table itself is compacted, since that would in turn cause new compactions
|
||||
if (ksname == "system" && cfname == COMPACTION_HISTORY) {
|
||||
return make_ready_future<>();
|
||||
@@ -2879,7 +2876,7 @@ future<> system_keyspace::update_compaction_history(utils::UUID uuid, sstring ks
|
||||
, COMPACTION_HISTORY);
|
||||
|
||||
db_clock::time_point tp{db_clock::duration{compacted_at}};
|
||||
return qctx->execute_cql(req, uuid, ksname, cfname, tp, bytes_in, bytes_out,
|
||||
return execute_cql(req, uuid, ksname, cfname, tp, bytes_in, bytes_out,
|
||||
make_map_value(map_type, prepare_rows_merged(rows_merged))).discard_result().handle_exception([] (auto ep) {
|
||||
slogger.error("update compaction history failed: {}: ignored", ep);
|
||||
});
|
||||
|
||||
@@ -306,7 +306,7 @@ public:
|
||||
std::unordered_map<int32_t, int64_t> rows_merged;
|
||||
};
|
||||
|
||||
static future<> update_compaction_history(utils::UUID uuid, sstring ksname, sstring cfname, int64_t compacted_at, int64_t bytes_in, int64_t bytes_out,
|
||||
future<> update_compaction_history(utils::UUID uuid, sstring ksname, sstring cfname, int64_t compacted_at, int64_t bytes_in, int64_t bytes_out,
|
||||
std::unordered_map<int32_t, int64_t> rows_merged);
|
||||
using compaction_history_consumer = noncopyable_function<future<>(const compaction_history_entry&)>;
|
||||
static future<> get_compaction_history(compaction_history_consumer&& f);
|
||||
|
||||
Reference in New Issue
Block a user