Commit Graph

334 Commits

Author SHA1 Message Date
Piotr Sarna
84876a165b db,schema_tables: add handling user-defined aggregates
Aggregates are propagated, created and dropped very similarly
to user-defined functions - a set of helper functions
for aggregates are added based on the UDF implementation.
2021-08-13 11:14:11 +02:00
Avi Kivity
3b5e312800 db: schema_tables: clean up read_schema_partition_for_keyspace() coroutine captures
read_schema_partition_for_keyspace() copies some parameters to capture them
in a coroutine, but the same can be achieved more cleanly by changing the
reference parameters to value parameters, so do that.

Test: unit (dev)

Closes #9154
2021-08-08 12:55:10 +03:00
Asias He
6350a19f73 compaction: Move compaction_strategy.hh to compaction dir
The top dir is a mess. Move compaction_strategy.hh and
compaction_strategy_type.hh to the new home.
2021-08-07 08:06:37 +08:00
Avi Kivity
885ca2158e db: schema_tables: reindent
Following conversion to corotuines in fc91e90c59, remove extra
indents and braces left to make the change clearer.

One variable had to be renamed since without the braces it
duplicated another variable in the same block.

Test: unit (dev)

Closes #9125
2021-08-02 22:36:57 +02:00
Avi Kivity
ca59754e68 db: schema_tables: drop now redundant #includes 2021-08-01 20:13:15 +03:00
Avi Kivity
40fdbf9558 db: schema_tables: coroutinize drop_column_mapping() 2021-08-01 20:13:15 +03:00
Avi Kivity
7d46300af2 db: schema_tables: coroutinize column_mapping_exists() 2021-08-01 20:13:15 +03:00
Avi Kivity
74b2200f4d db: schema_tables: coroutinize get_column_mapping() 2021-08-01 20:13:15 +03:00
Avi Kivity
f19ca7aaaa db: schema_tables: coroutinize read_table_mutations() 2021-08-01 20:13:15 +03:00
Avi Kivity
81a2be17b6 db: schema_tables: coroutinize create_views_from_schema_partition() 2021-08-01 20:13:15 +03:00
Avi Kivity
15f2fd2a23 db: schema_tables: coroutinize create_views_from_table_row() 2021-08-01 20:13:15 +03:00
Avi Kivity
0843d441ff db: schema_tables: unpeel lw_shared_ptr in create_Tables_from_tables_partition()
The tables local is a lw_shared_ptr which is created and then refeferenced
before returning. It can be unpeeled to the pointed-to type, resulting in
one less allocation.
2021-08-01 20:13:15 +03:00
Avi Kivity
66054d24c4 db: schema_tables: coroutinize create_tables_from_tables_partition() 2021-08-01 20:13:15 +03:00
Avi Kivity
82ba3c5f4a db: schema_tables: coroutinize create_table_from_name() 2021-08-01 20:13:15 +03:00
Avi Kivity
862f491605 db: schema_tables: coroutinize read_table_mutations() 2021-08-01 20:13:15 +03:00
Avi Kivity
91c1a29808 db: schema_tables: coroutinize merge_keyspaces() 2021-08-01 20:13:15 +03:00
Avi Kivity
78fc05922b db: schema_tables: coroutinize do_merge_schema()
It is now using an internal thread, so unpeel is and replace
future::get() with co_await.
2021-08-01 20:13:15 +03:00
Avi Kivity
9680d9e76c db: schema_tables: futurize and coroutinize merge_functions()
Right now, merge_functions() expects to be called in a thread.
Remove that requirement by converting it into a coroutine and returning
a future.

De-threading helps reduce errors where something expects to be called
in a thread, but isn't.
2021-08-01 20:13:15 +03:00
Avi Kivity
9cbae212bf db: schema_tables: futurize and coroutinize user_types_to_drop::drop
user_types_to_drop::drop is a function object returning void, and expecting
to be called in a thread. Make it return a future and convert the
only value it is initialized to to a coroutine.

De-threading helps reduce errors where something expects to be called
in a thread, but isn't.
2021-08-01 20:13:15 +03:00
Avi Kivity
e5f28fc746 db: schema_tables: futurize and coroutinize merge_types()
Right now, merge_types() expects to be called in a thread.
Remove that requirement by converting it into a coroutine and returning
a future.

The [[nodiscard]] attribute is moved from the function to the
return type, since the function now returns a future which is
nodiscard anyway.

The lambda returned is not coroutinized (yet) since it's part
of the user_types_to_drop inner function that still returns void
and expects to be called in a thread.

De-threading helps reduce errors where something expects to be called
in a thread, but isn't.
2021-08-01 20:13:15 +03:00
Avi Kivity
c9584d50ee db: schema_tables: futurize and coroutinize merge_tables_and_views()
Right now, merge_tables_and_views() expects to be called in a thread.
Remove that requirement by converting it into a coroutine and returning
a future.

De-threading helps reduce errors where something expects to be called
in a thread, but isn't.
2021-08-01 20:13:15 +03:00
Avi Kivity
80fe158387 db: schema_tables: coroutinize store_column_mapping() 2021-08-01 20:13:15 +03:00
Avi Kivity
ee8b02f437 db: schema_tables: futurize and coroutinize read_tables_for_keyspaces()
Right now, read_tables_for_keyspaces() expects to be called in a thread.
Remove that requirement by converting it into a coroutine and returning
a future.

De-threading helps reduce errors where something expects to be called
in a thread, but isn't.
2021-08-01 20:13:15 +03:00
Avi Kivity
cd1003daad db: schema_tables: coroutinize read_table_names_of_keyspace() 2021-08-01 20:13:15 +03:00
Avi Kivity
000f7eabd5 db: schema_tables: coroutinize recalculate_schema_version() 2021-08-01 20:13:15 +03:00
Avi Kivity
95d33e9e86 db: schema_tables: coroutinize merge_schema() 2021-08-01 20:13:15 +03:00
Avi Kivity
25548f46dd db: schema_tables: introduce and use with_merge_lock()
Rather than open-coding merge_lock()/merge_unlock() pairs, introduce
and use a helper. This helps in coroutinization, since coroutines
don't support RAII with destructors that wait.
2021-08-01 20:13:15 +03:00
Avi Kivity
7b731ae2c6 db: schema_tables: coroutinize update_schema_version_and_announce() 2021-08-01 20:13:15 +03:00
Avi Kivity
385e0dcc2e db: schema_tables: coroutinize read_keyspace_mutation() 2021-08-01 20:13:15 +03:00
Avi Kivity
ef5df86b1f db: schema_tables: coroutinize read_schema_partition_for_table() 2021-08-01 20:13:15 +03:00
Avi Kivity
8841c2ba10 db: schema_tables: coroutinize read_schema_partition_for_keyspace()
Two reference parameters are copied rather than changing the signature,
to avoid a compile-the-world. It can be cleaned up post-merge.
2021-08-01 20:09:00 +03:00
Avi Kivity
d1876488f7 db: schema_tables: coroutinize query_partition_mutation() 2021-08-01 19:17:13 +03:00
Avi Kivity
35f9caf6a9 db: schema_tables: coroutinize read_schema_for_keyspaces() 2021-08-01 19:17:09 +03:00
Avi Kivity
7c0476251a db: schema_tables: coroutinize convert_schema_to_mutations() 2021-08-01 19:16:55 +03:00
Avi Kivity
921216e8e6 db: schema_tables: coroutinize calculate_schema_digest() 2021-08-01 19:16:50 +03:00
Avi Kivity
3dab308ddf db: schema_tables: coroutinize save_system_schema() 2021-08-01 19:16:40 +03:00
Avi Kivity
222ef17305 build, treewide: enable -Wredundant-move
Returning a function parameter guarantees copy elision and does not
require a std::move().  Enable -Wredundant-move to warn us that the
move is unneeded, and gain slightly more readable code. A few violations
are trivially adjusted.

Closes #9004
2021-07-11 12:53:02 +03:00
Pavel Emelyanov
96131349e8 schema_tables: Remove unused sharded<proxy> argument
Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2021-06-18 20:19:35 +03:00
Avi Kivity
98cdeaf0f2 schema_tables: make the_merge_lock thread_local
the_merge_lock is global, which is fine now because it is only used
in shard 0. However, if we run multiple nodes in a single process,
there will be multiple shard 0:s, and the_merge_lock will be accessed
from multiple threads. This won't work.

To fix, make it thread_local. It would be better to make it a member
of some controlling object, but there isn't one.

Closes #8858
2021-06-17 13:41:11 +03:00
Avi Kivity
a55b434a2b treewide: extent copyright statements to present day 2021-06-06 19:18:49 +03:00
Piotr Jastrzebski
76d7c761d1 schema: Stop using deprecated constructor
This is another boring patch.

One of schema constructors has been deprecated for many years now but
was used in several places anyway. Usage of this constructor could
lead to data corruption when using MX sstables because this constructor
does not set schema version. MX reading/writing code depends on schema
version.

This patch replaces all the places the deprecated constructor is used
with schema_builder equivalent. The schema_builder sets the schema
version correctly.

Fixes #8507

Test: unit(dev)

Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
Message-Id: <4beabc8c942ebf2c1f9b09cfab7668777ce5b384.1622357125.git.piotr@scylladb.com>
2021-05-30 11:58:27 +03:00
Avi Kivity
daeddda7cc treewide: remove inclusions of storage_proxy.hh from headers
storage_proxy.hh is huge and includes many headers itself, so
remove its inclusions from headers and re-add smaller headers
where needed (and storage_proxy.hh itself in source files that
need it).

Ref #1.
2021-04-20 21:23:00 +03:00
Kamil Braun
617813ba66 sys_dist_ks: new keyspace for system tables with Everywhere strategy
`system_distributed_everywhere` is a new keyspace that uses Everywhere
replication strategy. This is useful, for example, when we want to store
internal data that should be accessible by every node; the data can be
written using CL=ALL (e.g. during node operations such as node
bootstrap, which require all nodes to be alive - at least currently) and
then read by each node locally using CL=ONE (e.g. during node restarts).

Closes #8457
2021-04-19 11:22:57 +03:00
Eliran Sinvani
9162748b18 materialized views: create view schemas with proper base table
reference.

Newly created view schemas don't always have their base info,
this is bad since such schemas don't support read nor write.
This leaves us vulnerable to a race condition where there is
an attempt to use this schema for read or write. Here we initialize
the base reference and also reconfigure the view to conform to the
new computed column type, which makes it usable for write and not only
reads. We do it for views created in the migration manager following
announcements and also for copied schemas.
2021-03-07 12:50:42 +02:00
Eliran Sinvani
39cd9dae4e materialized views: Extract fix legacy schema into its own logic
We extract the logic for fixing the view schema into it's own
logic as we will need to use it in more places in the code.
This makes 'maybe_update_legacy_secondary_index_mv_schema' redundant since
it becomes a two liner wrapper for this logic. We also
remove it here and replace the call to it with the equivalent code.
2021-03-07 12:50:42 +02:00
Piotr Sarna
c5214eb096 treewide: remove timeout config from query options
Timeout config is now stored in each connection, so there's no point
in tracking it inside each query as well. This patch removes
timeout_config from query_options and follows by removing now
unnecessary parameters of many functions and constructors.
2021-02-25 17:20:27 +01:00
Eliran Sinvani
178ced9014 schema tables: Remove mutations to unknown tables when adapting schema
mutations

Whenever an alter table occurs, the mutations for the just altered table
are sent over to all of the replicas from the coordinator.
In a mixed cluster the mutations should be adapted to a specific version
of the schema. However, the adaptation that happens today doesn't omit
mutations to newly added schema tables, to be more specific, mutations
to the `computed_columns` table which doesn't exist for example in
version 2019.1
This makes altering a table during a rolling upgrade from 2019.1 to
2020.1 dangerous.
2021-02-11 13:48:55 +02:00
Eliran Sinvani
ff1ba9bc2b schema tables: Register 'scylla_tables' versions that were sent to other
nodes

In a mixed cluster there can be a situation where `scylla_tables` needs
to be  sent over to another node because a schema sync or because the
node pulls it because it is referenced by a frozen_mutation. The former
is not a problem since the sending node chooses the version to send.
However, the former is problematic since `scylla_tables` versions are not
registered anywhere.
This registers every `scylla_tables` schema version which is used to adapted
mutations since after this happens a schema pull for this version might
follow.
2021-02-11 13:47:16 +02:00
Pavel Emelyanov
a05adb8538 database: Remove global storage proxy reference
The db::update_keyspace() needs sharded<storage_proxy>
reference, but the only caller of it already has it and
can pass one as argument.

tests: unit(dev)

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
Message-Id: <20210205175611.13464-3-xemul@scylladb.com>
2021-02-08 12:59:46 +01:00
Pavel Solodovnikov
9d17a654a6 raft: use null_sharder for raft tables
Tests: unit(dev)

Signed-off-by: Pavel Solodovnikov <pa.solodovnikov@scylladb.com>
Message-Id: <20210201105300.110210-1-pa.solodovnikov@scylladb.com>
2021-02-01 18:52:04 +02:00