compaction_backlog_tracker: do not allow moving registered trackers

Currently, the moved-object's manager pointer is moved into the
constructed object, but without fixing the registration to
point to the moved-to object, causing #15248.

Although we could properly move the registration from
the moved-from object to the moved-to one, it is simpler
to just disallow moving a registered tracker, since it's
not needed anywhere. This way we just don't need to mess
with the trackers' registration.

With that in mind, when move-assigning a compaction_backlog_tracker
the existing tracker can remain registered.

Fixes scylladb/scylladb#15248

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2023-09-17 13:27:39 +03:00
parent 62a8a31be7
commit 4ad4b632b8

View File

@@ -2153,14 +2153,17 @@ compaction_backlog_tracker::compaction_backlog_tracker(compaction_backlog_tracke
: _impl(std::move(other._impl))
, _ongoing_writes(std::move(other._ongoing_writes))
, _ongoing_compactions(std::move(other._ongoing_compactions))
, _manager(std::exchange(other._manager, nullptr)) {
{
if (other._manager) {
on_internal_error(cmlog, "compaction_backlog_tracker is moved while registered");
}
}
compaction_backlog_tracker&
compaction_backlog_tracker::operator=(compaction_backlog_tracker&& x) noexcept {
if (this != &x) {
if (auto manager = std::exchange(_manager, x._manager)) {
manager->remove_backlog_tracker(this);
if (x._manager) {
on_internal_error(cmlog, "compaction_backlog_tracker is moved while registered");
}
_impl = std::move(x._impl);
_ongoing_writes = std::move(x._ongoing_writes);