view_update_generator: Register staging sstables in constructor

First, it's to fix the discarded future during the register. The
future is not actually such, as it's always the no-op ready one as
at that stage the view_update_generator is neither aborted nor is
in throttling state.

Second, this change is to keep database start-up code in main
shorter and cleaner. Registering staging sstables belongs to the
view_update_generator start code.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2021-09-03 12:36:34 +03:00
parent a4118a70ee
commit 0de69136d4
3 changed files with 17 additions and 12 deletions

View File

@@ -25,6 +25,7 @@
#include "service/priority_manager.hh"
#include "utils/error_injection.hh"
#include "db/view/view_updating_consumer.hh"
#include "sstables/sstables.hh"
static logging::logger vug_logger("view_update_generator");
@@ -181,4 +182,18 @@ void view_update_generator::setup_metrics() {
});
}
void view_update_generator::discover_staging_sstables() {
for (auto& x : _db.get_column_families()) {
table& t = *(x.second);
for (auto sstables = t.get_sstables(); sstables::shared_sstable sst : *sstables) {
if (sst->requires_view_building()) {
_sstables_with_tables[t.shared_from_this()].push_back(std::move(sst));
// we're at early stage here, no need to kick _pending_sstables (the
// bulding fiber is not running), neither we can wait on the semaphore
_registration_sem.consume(1);
}
}
}
}
}

View File

@@ -46,6 +46,7 @@ private:
public:
view_update_generator(database& db) : _db(db) {
setup_metrics();
discover_staging_sstables();
}
future<> start();
@@ -56,6 +57,7 @@ public:
private:
bool should_throttle() const;
void setup_metrics();
void discover_staging_sstables();
};
}

12
main.cc
View File

@@ -997,18 +997,6 @@ int main(int ac, char** av) {
supervisor::notify("starting view update generator");
view_update_generator.start(std::ref(db)).get();
supervisor::notify("discovering staging sstables");
db.invoke_on_all([] (database& db) {
for (auto& x : db.get_column_families()) {
table& t = *(x.second);
for (auto sstables = t.get_sstables(); sstables::shared_sstable sst : *sstables) {
if (sst->requires_view_building()) {
// FIXME: discarded future.
(void)view_update_generator.local().register_staging_sstable(std::move(sst), t.shared_from_this());
}
}
}
}).get();
supervisor::notify("setting up system keyspace");
db::system_keyspace::setup(db, qp, feature_service, messaging).get();