Commit Graph

189 Commits

Author SHA1 Message Date
Botond Dénes
ceb0b02ee8 test: simple_schema: add make_static_row() 2020-09-28 11:27:49 +03:00
Botond Dénes
6ca0464af5 mutation_fragment: add schema and permit
We want to start tracking the memory consumption of mutation fragments.
For this we need schema and permit during construction, and on each
modification, so the memory consumption can be recalculated and pass to
the permit.

In this patch we just add the new parameters and go through the insane
churn of updating all call sites. They will be used in the next patch.
2020-09-28 11:27:23 +03:00
Botond Dénes
3fab83b3a1 flat_mutation_reader: impl: add reader_permit parameter
Not used yet, this patch does all the churn of propagating a permit
to each impl.

In the next patch we will use it to track to track the memory
consumption of `_buffer`.
2020-09-28 10:53:48 +03:00
Botond Dénes
5e5c94b064 test/lib/reader_lifecycle_policy: don't destroy reader context eagerly
Currently per-shard reader contexts are cleaned up as soon as the reader
itself is destroyed. This causes two problems:
* Continuations attached to the reader destroy future might rely on
  stuff in the context being kept alive -- like the semaphore.
* Shard 0's semaphore is special as it will be used to account buffers
  allocated by the multishard reader itself, so it has to be alive until
  after all readers are destroyed.

This patch changes this so that contexts are destroyed only when the
lifecycle policy itself is destroyed.
2020-09-28 08:46:22 +03:00
Avi Kivity
2bd264ec6a sstables: remove background_jobs(), await_background_jobs()
There are no more users for registering background jobs, so remove
the mechanism and the remaining calls.
2020-09-23 20:55:17 +03:00
Avi Kivity
ad8620c289 test: test_env: hold sstables_manager with a unique_ptr
sstables_manager should not be movable (since sstables hold a reference
to it). A following patch will enforce it.

Prepare by using unique_ptr to hold test_env::_manager. Right now, we'll
invoke sstables_manager move construction when creating a test_env with
do_with().

We could have chosen to update sstables when their sstables_manager is
moved, but we get nothing for the complexity.
2020-09-23 20:55:16 +03:00
Avi Kivity
fd61ebb095 test: drop test_sstable_manager
With no users left (apart from some variants of column_family_test_config
which are removed in this patch) there are no more users, so remove it.

test_sstable_manager is obstructs sstables_manager from taking charge
of sstables ownership, since it a thread-local object. We can't close it,
since it will be used in the next test to run.
2020-09-23 20:55:16 +03:00
Avi Kivity
d4c1b62f81 test: sstables::test_env: take ownership of manager
Instead of using test_sstables_manager, which we plan to drop,
carry our own sstables_manager in test_env, and close it when
test_env::stop() is called.
2020-09-23 20:55:16 +03:00
Avi Kivity
8c3ae648d9 test: sstable_utils: close test_env after use
test_env will soon manage its sstable_manager's lifetime, which
requires closing, so close the test_env.
2020-09-23 20:55:15 +03:00
Avi Kivity
1dd3079d67 test: sstables::test_env: close self in do_with helpers
The test_env::do_with() are convenient for creating a scope
containing a test_env. Prepare them for asynchronously closed
sstables_manager by closing the test_env after use (which will,
in the future, close the embedded sstables_manager).
2020-09-23 20:55:14 +03:00
Avi Kivity
85087478fc test: lib: sstable_utils: stop using test_sstables_manager
It will be retured soon. Extract the sstable_manager from the sstable itself.
2020-09-23 20:55:10 +03:00
Avi Kivity
9399f06e86 test: sstables test_env: introduce do_with_async_sharded()
Some tests need a test_env across multiple shard. Introduce a variant
of do_with_async() that supplies it.
2020-09-23 20:55:10 +03:00
Avi Kivity
a8e7c04fc9 test: sstables test_env: introduce do_with_async_returning()
Similar to do_with_async(), but returning a non-void return type.
Will be used in test/perf.
2020-09-23 20:55:09 +03:00
Avi Kivity
784d29a75b test: lib: sstable test_env: prepare for life as a sharded<> service
Some tests need a sharded sstables_manager, prepare for that by
adding a stop() method and helpers for creating a sharded service.

Since test_env doesn't yet contain its own sstable_manager, this
can't be used in real life yet.
2020-09-23 20:55:09 +03:00
Avi Kivity
0fbdb009d5 test: lib: test_services: pass sstables_manager to column_family_test_config
Since we're dropping test_sstables_manager, we'll require callers to pass it
to column_family_test_config, so provide overloads that accept it.

The original overloads (that don't accept an sstables_manager) remain for
the transition period.
2020-09-23 20:55:07 +03:00
Avi Kivity
72c13199d8 test: lib: sstables test_env: implement tests_env::manager()
Some tests are now referencing the global test_sstables_manager,
which we plan to remove. Add test_env::manager() as a way to
reference the sstables_manager that the test_env contains.
2020-09-23 20:55:07 +03:00
Avi Kivity
956cd9ee8d test: sstable_test_env: detemplate do_with_async()
Reduce code bloat and improve error messages by using noncopyable_function<>
instead of a template.
2020-09-23 20:55:06 +03:00
Pavel Emelyanov
2d45d71413 test: Do not init messaging verbs
The CQL tests do not use networking, so there is no need in registering any verbs

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2020-09-17 09:51:33 +03:00
Avi Kivity
392e24d199 Merge "Unglobal messaging service" from Pavel E
"
The messaging service is (as many other services) present in
the global namespace and is widely accessed from where needed
with global get(_local)?_messaging_service() calls. There's a
long-term task to get rid of this globality and make services
and componenets reference each-other and, for and due-to this,
start and stop in specific order. This set makes this for the
messaging service.

The service is very low level and doesn't depend on anything.
It's used by gossiper, streaming, repair, migration manager,
storage proxy, storage service and API. According to this
dependencies the set consists of several parts:

patches 1-9 are preparatory, they encapsulate messaging service
init/fini stuff in its own module and decouple it from the
db::config

patch 10-12 introduce local service reference in main and set
its init/fini calls at the early stage so that this reference
can later be passed to those depending on it

patches 13-42 replace global referencing of messaging service
from other subsystems with local references initialized from
main.

patch 43 finalizes tests.

patch 44 wraps things up with removing global messaiging service
instance along with get(_local)?_messaging_service calls.

The service's stopping part is deliberately left incomplete (as
it is now), the sharded service remains alive, only the instance's
stop() method is called (and is empty for a while). Since the
messaging service's users still do not stop cleanly, its instances
should better continue leaking on exit.

Once (if) the seastar gets the helper rpc::has_handlers() method
merged the messaging_service::stop() will be able to check if all
the verbs had been unregistered (spoiler: not yet, more fixes to
come).

For debugging purposes the pointer on now-local messaging service
instance is kept in service::debug namespace.

tests: unit(dev)
       dtest(dev: simple_boot_shutdown, repair, update_cluster_layout)
       manual start-stop
"

* 'br-unglobal-messaging-service-2' of https://github.com/xemul/scylla: (44 commits)
  messaging_service: Unglobal messaging service instance
  tests: Use own instances of messaging_service
  storage_service: Use local messaging reference
  storage_service: Keep reference on sharded messaging service
  migration_manager: Add messaging service as argument to get_schema_definition
  migration_manager: Use local messaging reference in simple cases
  migration_manager: Keep reference on messaging
  migration_manager: Make push_schema_mutation private non-static method
  migration_manager: Move get_schema_version verb handling from proxy
  repair: Stop using global messaging_service references
  repair: Keep sharded messaging service reference on repair_meta
  repair: Keep sharded messaging service reference on repair_info
  repair: Keep reference on messaging in row-level code
  repair: Keep sharded messaging service in API
  repair: Unset API endpoints on stop
  repair: Setup API endpoints in separate helper
  repair: Push the sharded<messaging_service> reference down to sync_data_using_repair
  repair: Use existing sharded db reference
  repair: Mark repair.cc local functions as static
  streaming: Keep messaging service on send_info
  ...
2020-08-20 12:20:36 +03:00
Pavel Emelyanov
ee41645a1a tests: Use own instances of messaging_service
The global one is going away, no core code uses it, so all tests
can be safely switched to use their own instances.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2020-08-19 20:50:53 +03:00
Pavel Emelyanov
4ea3c2797c storage_service: Keep reference on sharded messaging service
It is a bit step backward in the storage-service decompsition campaign, but...

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2020-08-19 20:50:53 +03:00
Pavel Emelyanov
6c49127d04 migration_manager: Keep reference on messaging
That's another user of messaging service, init it with private reference.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2020-08-19 20:50:53 +03:00
Pavel Emelyanov
24cb1b781f storage_proxy: Keep reference on messaging
The proxy is another user of messaging, so keep the reference on it. Its
real usage will come in next patches.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2020-08-19 20:50:52 +03:00
Pavel Emelyanov
65bd54604d gossiper: Use messaging service by reference
Gossiper needs messaging service, the messaging is started before the
gossiper, so we can push the former reference into it.

Gossiper is not stopped for real, neither the messaging service is, so
the memory usage is still safe.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2020-08-19 20:50:52 +03:00
Botond Dénes
6ad80f0adb test/lib/cql_test_env: set debug::db pointer
To allow using scylla-gdb.py scripts for debugging tests. These scripts
expect a valid database pointer in `debug::db`.

Signed-off-by: Botond Dénes <bdenes@scylladb.com>
Message-Id: <20200819145632.2423462-1-bdenes@scylladb.com>
2020-08-19 19:13:05 +03:00
Pavel Emelyanov
dc0918e255 tests: Keep local reference on global messaging
Some tests directly reference the global messaging service. For the sake
of simpler patching wrap this global reference with a local one. Once the
global messaging service goes away tests will get their own instances.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2020-08-19 13:08:12 +03:00
Raphael S. Carvalho
81ec49c82f sstables/sstable_set: rename method to retrieve sstable runs
select() is too generic for the method that retrieve sstable runs,
and it has a completely different meaning that the former select
method used to select sstables based on token range.
let's give it a more descriptive name.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
Message-Id: <20200811193401.22749-1-raphaelsc@scylladb.com>
2020-08-16 17:41:16 +03:00
Piotr Jastrzebski
c001374636 codebase wide: replace count with contains
C++20 introduced `contains` member functions for maps and sets for
checking whether an element is present in the collection. Previously
`count` function was often used in various ways.

`contains` does not only express the intend of the code better but also
does it in more unified way.

This commit replaces all the occurences of the `count` with the
`contains`.

Tests: unit(dev)

Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
Message-Id: <b4ef3b4bc24f49abe04a2aba0ddd946009c9fcb2.1597314640.git.piotr@scylladb.com>
2020-08-15 20:26:02 +03:00
Botond Dénes
1d48442ae7 test/lib/mutation_source_test: test-monotonic-positions: test the reader-under-test
Instead of always testing `flat_mutation_reader_from_mutations()`.

Tests: unit(dev, debug)

Signed-off-by: Botond Dénes <bdenes@scylladb.com>
Message-Id: <20200812073406.1681250-1-bdenes@scylladb.com>
2020-08-12 10:52:26 +03:00
Rafael Ávila de Espíndola
aa2476d7ac test: Move code in sstable_run_based_compaction_strategy_for_tests.hh out of line
Most of this is virtual and it is all test code.

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
2020-08-11 11:49:49 -07:00
Rafael Ávila de Espíndola
ef6a52a407 test: Drop ifdef now that we always use c++20
Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
2020-08-11 11:49:20 -07:00
Rafael Ávila de Espíndola
bd2f9fc685 test: Move sstable_run_based_compaction_strategy_for_tests.hh to test/lib
This is in preparation to moving the code to a .cc file.

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
2020-08-11 11:48:41 -07:00
Avi Kivity
3530e80ce1 Merge "Support md format" from Benny
"
This series adds support for the "md" sstable format.

Support is based on the following:

* do not use clustering based filtering in the presence
  of static row, tombstones.
* Disabling min/max column names in the metadata for
  formats older than "md".
* When updating the metadata, reset and disable min/max
  in the presence of range tombstones (like Cassandra does
  and until we process them accurately).
* Fix the way we maintain min/max column names by:
  keeping whole clustering key prefixes as min/max
  rather than calculating min/max independently for
  each component, like Cassandra does in the "md" format.

Fixes #4442

Tests: unit(dev), cql_query_test -t test_clustering_filtering* (debug)
md migration_test dtest from git@github.com:bhalevy/scylla-dtest.git migration_test-md-v1
"

* tag 'md-format-v4' of github.com:bhalevy/scylla: (27 commits)
  config: enable_sstables_md_format by default
  test: cql_query_test: add test_clustering_filtering unit tests
  table: filter_sstable_for_reader: allow clustering filtering md-format sstables
  table: create_single_key_sstable_reader: emit partition_start/end for empty filtered results
  table: filter_sstable_for_reader: adjust to md-format
  table: filter_sstable_for_reader: include non-scylla sstables with tombstones
  table: filter_sstable_for_reader: do not filter if static column is requested
  table: filter_sstable_for_reader: refactor clustering filtering conditional expression
  features: add MD_SSTABLE_FORMAT cluster feature
  config: add enable_sstables_md_format
  database: add set_format_by_config
  test: sstable_3_x_test: test both mc and md versions
  test: Add support for the "md" format
  sstables: mx/writer: use version from sstable for write calls
  sstables: mx/writer: update_min_max_components for partition tombstone
  sstables: metadata_collector: support min_max_components for range tombstones
  sstable: validate_min_max_metadata: drop outdated logic
  sstables: rename mc folder to mx
  sstables: may_contain_rows: always true for old formats
  sstables: add may_contain_rows
  ...
2020-08-11 13:29:11 +03:00
Benny Halevy
65239a6e50 config: add enable_sstables_md_format
MD format is disabled by default at this point.

The option extends enable_sstables_mc_format
so that both are needed to be set for supporting
the md format.

The MD_FORMAT cluster feature will be added in
a following patch.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2020-08-10 18:53:04 +03:00
Benny Halevy
8e0e2c8a48 database: add set_format_by_config
This is required for test applications that may select a sstable
format different than the default mc format, like perf_fast_forward.

These apps don't use the gossip-based sstables_format_selector
to set the format based on the cluster feature and so they
need to rely on the db config.

Call set_format_by_config in single_node_cql_env::do_with.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2020-08-10 18:53:04 +03:00
Benny Halevy
69f7454d88 sstable: mark read_toc and methods calling it noexcept
read_toc can be marked as noexcept now that new_sstable_component_file is.
With that, other methods that call it can be marked noexcept too.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2020-08-09 12:04:36 +03:00
Rafael Ávila de Espíndola
b1315a2120 cql_test_env: Delay starting the compaction manager
In case of an initialization failure after

  db.get_compaction_manager().enable();

But before stop_database, we would never stop the compaction manager
and it would assert during destruction.

I am trying to add a test for this using the memory failure injector,
but that will require fixing other crashes first.

Found while debugging #6831.

Refs #6831.

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
Message-Id: <20200805181840.196064-1-espindola@scylladb.com>
2020-08-06 16:07:16 +03:00
Rafael Ávila de Espíndola
ef0bed7253 Drop duplicated 'if' in comment
Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
Message-Id: <20200730170109.5789-1-espindola@scylladb.com>
2020-08-04 07:53:34 +03:00
Calle Wilund
30a700c5b0 system_keyspace: Remove support for legacy truncation records
Fixes #6341

Since scylla no longer supports upgrading from a version without the
"new" (dedicated) truncation record table, we can remove support for these
and the migtration thereof.

Make sure the above holds whereever this is committed.

Note that this does not  remove the "truncated_at" field in
system.local.
2020-08-03 17:16:26 +03:00
Avi Kivity
257c17a87a Merge "Don't depend on seastar::make_(lw_)?shared idiosyncrasies" from Rafael
"
While working on another patch I was getting odd compiler errors
saying that a call to ::make_shared was ambiguous. The reason was that
seastar has both:

template <typename T, typename... A>
shared_ptr<T> make_shared(A&&... a);

template <typename T>
shared_ptr<T> make_shared(T&& a);

The second variant doesn't exist in std::make_shared.

This series drops the dependency in scylla, so that a future change
can make seastar::make_shared a bit more like std::make_shared.
"

* 'espindola/make_shared' of https://github.com/espindola/scylla:
  Everywhere: Explicitly instantiate make_lw_shared
  Everywhere: Add a make_shared_schema helper
  Everywhere: Explicitly instantiate make_shared
  cql3: Add a create_multi_column_relation helper
  main: Return a shared_ptr from defer_verbose_shutdown
2020-08-02 19:51:24 +03:00
Rafael Ávila de Espíndola
a548e5f5d1 test: Mark tmpdir::remove noexcept
Also disable the allocation failure injection in it.

Refs #6831.

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
Message-Id: <20200729200019.250908-2-espindola@scylladb.com>
2020-07-30 09:55:52 +03:00
Rafael Ávila de Espíndola
d8ba9678b4 test: Move tmpdir code to a .cc file
This is not hot, so we can move it out of the header.

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
Message-Id: <20200729200019.250908-1-espindola@scylladb.com>
2020-07-30 09:55:52 +03:00
Botond Dénes
43c0da4b63 test: cql_test_env: set the max_memory_unlimited_query_{soft,hard}_limit
To an unlimited value, in order to avoid aborting any unpaged queries
executed by tests, that would exceed the default result limit of
1MB/100MB.
2020-07-28 18:00:29 +03:00
Botond Dénes
92ce39f014 query: query_class_config: use max_result_size for the max_memory_for_unlimited_query field
We want to switch from using a single limit to a dual soft/hard limit.
As a first step we switch the limit field of `query_class_config` to use
the recently introduced type for this. As this field has a single user
at the moment -- reverse queries (and not a lot of propagation) -- we
update it in this same patch to use the soft/hard limit: warn on
reaching the soft limit and abort on the hard limit (the previous
behaviour).
2020-07-28 18:00:29 +03:00
Botond Dénes
517a941feb query_class_config: move into the query namespace
It belongs there, its name even starts with "query".
2020-07-28 18:00:29 +03:00
Rafael Ávila de Espíndola
e15c8ee667 Everywhere: Explicitly instantiate make_lw_shared
seastar::make_lw_shared has a constructor taking a T&&. There is no
such constructor in std::make_shared:

https://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared

This means that we have to move from

    make_lw_shared(T(...)

to

    make_lw_shared<T>(...)

If we don't want to depend on the idiosyncrasies of
seastar::make_lw_shared.

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
2020-07-21 10:33:49 -07:00
Botond Dénes
f264d2b00f test: cql_test_env: allow overriding database_config 2020-07-20 11:23:39 +03:00
Rafael Ávila de Espíndola
b10beead61 memtable_snapshot_source: Avoid a std::bad_alloc crash
_should_compact is a condition_variable and condition_variable::wait()
allocates memory.

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
Message-Id: <20200706223201.903072-1-espindola@scylladb.com>
2020-07-08 15:21:50 +02:00
Rafael Ávila de Espíndola
33af0c293f cql_test_env: Make ks_name a constexpr std::string_view
Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
2020-07-03 12:28:20 -07:00
Botond Dénes
63309f925c mutation_reader: reader_lifecycle_policy: make semaphore() available early
Currently all reader lifecycle policy implementations assume that
`semaphore()` will only be called after at least one call to
`make_reader()`. This assumption will soon not hold, so make sure
`semaphore()` can be called at any time, including before any calls are
made to `make_reader()`.
2020-06-23 10:01:38 +03:00