Commit Graph

23 Commits

Author SHA1 Message Date
Patryk Jędrzejczak
4ff08decb8 virtual_tables: cluster_status_table: execute: set dc regardless of the token ownership
If a node is in `locator::topology`, then it has a location.
We remove the token ownership condition to make the table more
descriptive.
2024-08-29 10:37:06 +02:00
Raphael S. Carvalho
ad5c5bca5f replica: get rid of fragile compaction group intrusive list
It was added to make integration of storage groups easier, but it's
complicated since it's another source of truth and we could have
problems if it becomes inconsistent with the group map.

Fixes #18506.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
2024-07-09 16:53:35 -03:00
Pavel Emelyanov
627c5fdf04 virtual_tables: Open-code install_virtual_readers_and_writers()
It's pretty short already and is naturally a "part" of
initialize_virtual_tables(). Neither it installs writers any longer.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-04-01 19:02:40 +03:00
Pavel Emelyanov
1d79cfc6cf virtual_tables: Move readers setup loop into add_table()
Similarly to previous patch, after virtual tables are registered the
registry is iterated over to install virtual readers onto each entry.
Again, this can happen at the time of registering, no need in dedicated
loop for that.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-04-01 19:01:50 +03:00
Pavel Emelyanov
891e792717 virtual_tables: Move tables creation loop into add_table()
Once virtual_tables map is populated, it's iterated over to create
replica::table entries for each virtual table. This can be done in the
same place where the virtual table is created, no need in dedicated loop
for it nowadays.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-04-01 19:00:38 +03:00
Pavel Emelyanov
420ce3634f virtual_tables: Make add_tablet() a coroutine
Next patches will populate it with sleeping calls, this patch prepares
for that.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-04-01 19:00:15 +03:00
Pavel Emelyanov
ddc6f9279f virtual_tables: Open-code register_virtual_tables()
It's naturally a "part" of initialize_virtual_tables(). Further patching
gets possible with it being open-coded.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-04-01 18:59:18 +03:00
Botond Dénes
279e496133 db/virtual_tables: token_ring_table: add tablet support
For keyspaces which use tablets, we describe each table separately.
2024-03-15 04:23:20 -04:00
Botond Dénes
61b6ac7ffe db/virtual_tables: token_ring_table: add table_name column
As the first clustering column. For vnode keyspaces, this will always be
"ALL", for tablet keyspaces, this will contain the name of the described
table.
2024-03-15 04:23:20 -04:00
Botond Dénes
fdef62c232 db/virtual_tables: token_ring_table: extract ring emit
Into a separate method. For vnodes there is a single ring per keyspace,
but for tablets, there is a separate ring for each table in the
keyspace. To accomodate both, we move the code emitting the ring into a
separate method, so execute() can just call it once per keyspace or once
per table, whichever appropriate.
2024-03-15 04:23:20 -04:00
Gleb Natapov
461bba08cb virtual_tables: take node state from raft for cluster_status_table table if topology over raft is enabled
If topology over raft is enabled the most up-to-date node status is in
the topology state machine. Get it from there.
2024-02-19 15:01:33 +02:00
Gleb Natapov
eb6fa81714 virtual_tables: create result for cluster_status_table read on shard 0
Next patch will access data that is available only on shard 0 during
result creation.
2024-02-19 15:01:33 +02:00
Kefu Chai
be364d30fd db: do not include unused headers
these unused includes were identified by clangd. see
https://clangd.llvm.org/guides/include-cleaner#unused-include-warning
for more details on the "Unused include" warning.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#16664
2024-01-09 11:44:19 +02:00
Avi Kivity
2853f79f96 virtual_tables: scope virtual tables registry in system_keyspace
Virtual tables are kept in a thread_local registry for deduplication
purposes. The problem is that thread_local variables are destroyed late,
possibly after the schema registry and the reactor are destroyed.
Currently this isn't a problem, but after a seastar change to
destroy the reactor after termination [1], things break.

Fix by moving the registry to system_keyspace. system_keyspace was chosen
since it was the birthplace of virtual tables.

Pimpl is used to avoid increasing dependencies.

[1] 101b245ed7
2023-12-21 16:19:42 +02:00
Petr Gusev
7b55ccbd8e token_metadata: drop the template
Replace token_metadata2 ->token_metadata,
make token_metadata back non-template.

No behavior changes, just compilation fixes.
2023-12-12 23:19:54 +04:00
Petr Gusev
309e08e597 storage_service: get_token_metadata -> token_metadata2
In this commit we change the return type of
storage_service::get_token_metadata_ptr() to
token_metadata2_ptr and fix whatever breaks.

All the boost and topology tests pass with this change.
2023-12-12 23:19:53 +04:00
Petr Gusev
beb29f094b system_keyspace: drop load phases
We want to switch system.scylla_local table to the
schema commitlog, but load phases hamper here - schema
commitlog is initialized after phase1,
so a table which is using it should be moved to phase2,
but system.scylla_local contains features, and we need
them before  schema commitlog initialization for
SCHEMA_COMMITLOG feature.

In this commit we are taking a different approach to
loading system tables. First, we load them all in
one pass in 'readonly' mode. In this mode, the table
cannot be written to and has not yet been assigned
a commit log. To achieve this we've added _readonly bool field
to the table class, it's initialized to true in table's
constructor. In addition, we changed the table constructor
to always assign nullptr to commitlog, and we trigger
an internal error if table.commitlog() property is accessed
while the table is in readonly mode. Then, after
triggering on_system_tables_loaded notifications on
feature_service and sstable_format_selector, we call
system_keyspace::mark_writable and eventually
table::mark_ready_for_writes which selects the
proper commitlog and marks the table as writable.

In sstable_compaction_test we drop several
mark_ready_for_writes calls since they are redundant,
the table has already been made writable in
env.make_table_for_tests call.

The table::commitlog function either returns the current
commitlog or causes an error if the table is readonly. This
didn't work for virtual tables, since they never called
mark_ready_for_writes. In this commit we add this
call to initialize_virtual_tables.
2023-09-13 23:17:20 +04:00
Petr Gusev
e395086557 system_keyspace: move initialize_virtual_tables into virtual_tables.hh
This is a readability refactoring commit without observable changes
in behaviour.

initialize_virtual_tables logically belongs to virtual_tables module,
and it allows to make other functions in virtual_tables.cc
(register_virtual_tables, install_virtual_readers)
local to the module, which simplifies the matters a bit.

all_virtual_tables() is not needed anymore, all the references to
registered virtual tables are now local to virtual_tables module
and can just use virtual_tables variable directly.
2023-09-13 23:00:15 +04:00
Benny Halevy
4f5ffc7719 gossiper: add for_each_endpoint_state helpers
Before changing _endpoint_state_map to hold a
lw_shared_ptr<endpoint_state>, provide synchronous helpers
for users to traverse all endpoint_states with no need
to copy them (as long as the called func does not yield).

With that, gossiper::get_endpoint_states() can be made private.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2023-08-31 08:32:31 +03:00
Aleksandra Martyniuk
cdbfa0b2f5 replica: iterate safely over tables related maps
Loops over _column_families and _ks_cf_to_uuid which may preempt
are protected by reader mode of rwlock so that iterators won't
get invalid.
2023-07-25 17:13:04 +02:00
Aleksandra Martyniuk
52afd9d42d replica: wrap column families related maps into tables_metadata
As a preparation for ensuring access safety for column families
related maps, add tables_metadata, access to members of which
would be protected by rwlock.
2023-07-25 16:13:00 +02:00
Kefu Chai
fa3129fa29 treewide: use unsigned variable to compare with unsigned
some times we initialize a loop variable like

auto i = 0;

or

int i = 0;

but since the type of `0` is `int`, what we get is a variable of
`int` type, but later we compare it with an unsigned number, if we
compile the source code with `-Werror=sign-compare` option, the
compiler would warn at seeing this. in general, this is a false
alarm, as we are not likely to have a wrong comparison result
here. but in order to prevent issues due to the integer promotion
for comparison in other places. and to prepare for enabling
`-Werror=sign-compare`. let's use unsigned to silence this warning.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-07-18 10:27:18 +08:00
Botond Dénes
296837120d db: move virtual tables into virtual_tables.cc
The definitions of virtual tables make up approximately a quarter of the
huge system_keyspace.cc file (almost 4K lines), pulling in a lot of
headers only used by them.
Move them to a separate source file to make system_keyspace.cc easier
for humans and compilers to digest.
This patch also moves the `register_virtual_tables()`,
`install_virtual_readers()` as well as the `virtual_tables` global.

Closes #14308
2023-07-12 15:26:54 +03:00