view: Plug view update generator to database

The database is low-level service and currently view update generator
implicitly depend on it via storage proxy. However, database does need
to push view updates with the help of mutate_MV helper, thus adding the
dependency loop.

This patch exploits the fact that view updates start being pushed late
enough, by that time all other service, including proxy and view update
generator, seem to be up and running. This allows a "weak dependency"
from database to view update generator, like there's one from database
to system keyspace already.

So in this patch the v.u.g. puts the shared-from-this pointer onto the
database at the time it starts. On stop it removes this pointer after
database is drained and (hopefully) all view updates are pushed.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2023-03-28 11:13:52 +03:00
parent 3455b1aed8
commit d5557ef0e2
4 changed files with 20 additions and 1 deletions

View File

@@ -97,6 +97,7 @@ view_update_generator::view_update_generator(replica::database& db, sharded<serv
setup_metrics();
discover_staging_sstables();
(void)_proxy;
_db.plug_view_update_generator(*this);
}
view_update_generator::~view_update_generator() {}
@@ -206,6 +207,7 @@ future<> view_update_generator::start() {
}
future<> view_update_generator::stop() {
_db.unplug_view_update_generator();
_as.request_abort();
_pending_sstables.signal();
return std::move(_started).then([this] {

View File

@@ -28,7 +28,7 @@ class storage_proxy;
namespace db::view {
class view_update_generator {
class view_update_generator : public async_sharded_service<view_update_generator> {
public:
static constexpr size_t registration_queue_size = 5;