The namespace usage in this directory is very inconsistent, with files
and classes scattered in:
* global namespace
* namespace compaction
* namespace sstables
With cases, where all three used in the same file. This code used to
live in sstables/ and some of it still retains namespace sstables as a
heritage of that time. The mismatch between the dir (future module) and
the namespace used is confusing, so finish the migration and move all
code in compaction/ to namespace compaction too.
This patch, although large, is mechanic and only the following kind of
changes are made:
* replace namespace sstable {} with namespace compaction {}
* add namespace compaction {}
* drop/add sstables::
* drop/add compaction::
* move around forward-declarations so they are in the correct namespace
context
This refactoring revealed some awkward leftover coupling between
sstables and compaction, in sstables/sstable_set.cc, where the
make_sstable_set() methods of compaction strategies are implemented.
66 lines
2.4 KiB
C++
66 lines
2.4 KiB
C++
/*
|
|
* Copyright (C) 2023-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <seastar/core/gate.hh>
|
|
#include <seastar/core/rwlock.hh>
|
|
#include <seastar/core/condition-variable.hh>
|
|
#include "seastarx.hh"
|
|
|
|
#include "compaction/compaction_fwd.hh"
|
|
#include "compaction/compaction_backlog_manager.hh"
|
|
#include "gc_clock.hh"
|
|
|
|
namespace compaction {
|
|
|
|
// There's 1:1 relationship between compaction_grop_view and compaction_state.
|
|
// Two or more compaction_group_view can be served by the same instance of sstable::sstable_set,
|
|
// so it's not safe to track any sstable state here.
|
|
struct compaction_state {
|
|
// Used both by compaction tasks that refer to the compaction_state
|
|
// and by any function running under run_with_compaction_disabled().
|
|
seastar::named_gate gate;
|
|
|
|
// Used for synchronizing selection of sstable for compaction.
|
|
// Write lock is held when getting sstable list, feeding them into strategy, and registering compacting sstables.
|
|
// The lock prevents two concurrent compaction tasks from picking the same sstables. And it also helps major
|
|
// to synchronize with minor, such that major doesn't miss any sstable.
|
|
seastar::rwlock lock;
|
|
|
|
// Compations like major need to work on all sstables in the unrepaired
|
|
// set, no matter if the sstable is being repaired or not. The
|
|
// incremental_repair_lock lock is introduced to serialize repair and such
|
|
// compactions. This lock guarantees that no sstables are being repaired.
|
|
// Note that the minor compactions do not need to take this lock because
|
|
// they ignore sstables that are being repaired.
|
|
seastar::rwlock incremental_repair_lock;
|
|
|
|
// Raised by any function running under run_with_compaction_disabled();
|
|
long compaction_disabled_counter = 0;
|
|
|
|
// Signaled whenever a compaction task completes.
|
|
condition_variable compaction_done;
|
|
|
|
// Used only with vnodes, will not work with tablets. Can be removed once vnodes are gone.
|
|
std::unordered_set<sstables::shared_sstable> sstables_requiring_cleanup;
|
|
compaction::owned_ranges_ptr owned_ranges_ptr;
|
|
|
|
gc_clock::time_point last_regular_compaction;
|
|
|
|
explicit compaction_state(compaction_group_view& t);
|
|
compaction_state(compaction_state&&) = delete;
|
|
~compaction_state();
|
|
|
|
bool compaction_disabled() const noexcept {
|
|
return compaction_disabled_counter > 0;
|
|
}
|
|
};
|
|
|
|
} // namespace compaction
|