Files
scylladb/db/virtual_tables.hh
Benny Halevy ce00d61917 db: implement large_data virtual tables with feature flag gating
Replace the physical system.large_partitions, system.large_rows, and
system.large_cells CQL tables with virtual tables that read from
LargeDataRecords stored in SSTable scylla metadata (tag 13).

The transition is gated by a new LARGE_DATA_VIRTUAL_TABLES cluster
feature flag:

- Before the feature is enabled: the old physical tables remain in
  all_tables(), CQL writes are active, no virtual tables are registered.
  This ensures safe rollback during rolling upgrades.

- After the feature is enabled: old physical tables are dropped from
  disk via legacy_drop_table_on_all_shards(), virtual tables are
  registered on all shards, and CQL writes are skipped via
  skip_cql_writes() in cql_table_large_data_handler.

Key implementation details:

- Three virtual table classes (large_partitions_virtual_table,
  large_rows_virtual_table, large_cells_virtual_table) extend
  streaming_virtual_table with cross-shard record collection.

- generate_legacy_id() gains a version parameter; virtual tables
  use version 1 to get different UUIDs than the old physical tables.

- compaction_time is derived from SSTable generation UUID at display
  time via UUID_gen::unix_timestamp().

- Legacy SSTables without LargeDataRecords emit synthetic summary
  rows based on above_threshold > 0 in LargeDataStats.

- The activation logic uses two paths: when the feature is already
  enabled (test env, restart), it runs as a coroutine; when not yet
  enabled, it registers a when_enabled callback that runs inside
  seastar::async from feature_service::enable().

- sstable_3_x_test updated to use a simplified large_data_test_handler
  and validate LargeDataRecords in SSTable metadata directly.
2026-04-16 08:49:02 +03:00

64 lines
1.2 KiB
C++

/*
* Modified by ScyllaDB
* Copyright (C) 2023-present ScyllaDB
*/
/*
* SPDX-License-Identifier: (LicenseRef-ScyllaDB-Source-Available-1.1 and Apache-2.0)
*/
#pragma once
#include <seastar/core/sharded.hh>
#include <map>
#include "schema/schema_fwd.hh"
namespace replica {
class database;
}
namespace service {
class storage_service;
class raft_group_registry;
class tablet_allocator;
}
namespace gms {
class feature_service;
class gossiper;
}
namespace netw {
class messaging_service;
}
namespace db {
class config;
class system_keyspace;
future<> initialize_virtual_tables(
sharded<replica::database>&,
sharded<service::storage_service>&,
sharded<gms::gossiper>&,
sharded<service::raft_group_registry>&,
sharded<db::system_keyspace>&,
sharded<service::tablet_allocator>&,
sharded<netw::messaging_service>&,
db::config&,
gms::feature_service&);
class virtual_table;
using virtual_tables_registry_impl = std::map<table_id, std::unique_ptr<virtual_table>>;
// Pimpl to hide virtual_table from the rest of the code
class virtual_tables_registry : public std::unique_ptr<virtual_tables_registry_impl> {
public:
virtual_tables_registry();
~virtual_tables_registry();
};
} // namespace db