Commit Graph

79 Commits

Author SHA1 Message Date
Paweł Dziepak
fde9e1d55f tests/mutation_reader: disambiguate freeze() overload
freeze() is about to get overloaded so make sure we don't get any
ambiguities.
2018-05-25 10:15:10 +01:00
Paweł Dziepak
7c5c77369a tests/mutation_reader: do not apply mutations created on another shard
Scylla uses shared-nothing architecture and communication between the
shards is supposed to be very restricted. Applying to a memtable
mutations created on another shard is way to complex operation to be
allowed. Using frozen mutations is a much safer option.
2018-05-09 16:52:26 +01:00
Botond Dénes
777f3c7dc2 mutation_reader_test: don't lock up with smp=1
test_foreign_reader_destroyed_with_pending_read_ahead lock up completely
when run with SMP=1. As a solution skip the test-case when SMP < 2.

Signed-off-by: Botond Dénes <bdenes@scylladb.com>
Message-Id: <815585c40a65a66f3b03e6393b46fbd6849c8ef5.1525866777.git.bdenes@scylladb.com>
2018-05-09 15:10:18 +03:00
Botond Dénes
5d5bc0e1ab mutation_reader_test: fix multishard-reader test with smp > 3
test_multishard_combining_reader_destroyed_with_pending_create_reader
was failing because it relied on smp == 3 and thus the shard on which
the reader creation is blocked being shard-2. Since the test requires to
be run with smp >= 3 we can hardcode this shard to be 2 because if the
test runs at all we are guaranteed to have at least smp >= 3.

Signed-off-by: Botond Dénes <bdenes@scylladb.com>
Message-Id: <38883a1f4c18ca0cd065aa13826a4f1858353289.1525328233.git.bdenes@scylladb.com>
2018-05-03 10:30:21 +03:00
Botond Dénes
efa08f623a mutation_reader_test: add description to multishard-tests
These tests are quite complicated and require intimate knowledge of how
foreign_reader and multishard_combining_reader operates. Knowing these
two objects is still required to understand the tests but make it that
much easier by explaining how they were designed to test what they test.

Signed-off-by: Botond Dénes <bdenes@scylladb.com>
Message-Id: <8de580131a8652924de920c2bc68a98e579398ee.1525328226.git.bdenes@scylladb.com>
2018-05-03 10:30:20 +03:00
Paweł Dziepak
bfc017daa8 tests/mutation_reader: do not capture on-stack variable by reference
'shard' is a short-lived on-stack variable that gets captured by
reference by continuation that gets executed on another shard.

Fixes a race condition that leads to an heap-use-after-free.

Message-Id: <20180502150507.2776-1-pdziepak@scylladb.com>
2018-05-02 18:07:37 +03:00
Botond Dénes
d80e586ccb mutation_reader_test: remove leftover comments
Signed-off-by: Botond Dénes <bdenes@scylladb.com>
Message-Id: <580dcf664fc4fc84f3a29137fba5c982f57d7601.1525269726.git.bdenes@scylladb.com>
2018-05-02 17:03:50 +03:00
Botond Dénes
e14b0ca13e mutation_reader_test: fix possible use-after-free
The test_foreign_reader_destroyed_with_pending_read_ahead test currently
doesn't ensure that the objects in it's scope are destroyed in the
correct order. This is necessary as there are severeal foreign pointers
to objects that live on remote shards and use each other. Since
foreign pointers destory their managed object in the background we
cannot rely on the to reliably destroy objects in order, nor can we be
sure when the object they manage is actually destroy.
So to work around that ensure that the puppet_reader is destroyed before
the remote_control it references even has a chance of being destroyed.

Signed-off-by: Botond Dénes <bdenes@scylladb.com>
Message-Id: <232eaa899878b03fb2a765c2916e4f05841472a3.1525269726.git.bdenes@scylladb.com>
2018-05-02 17:03:49 +03:00
Botond Dénes
79684eff8e mutation_reader_test: add read-ahead related multishard reader tests
Add tests for foreign_reader and multishard_combining_reader that check
that readers destroyed while there is pending read-head will not result
in use-after-free.
Specifically check that:
* multishard_combining_reader destroyed with pending reader creation
* foreign_reader destroyed with pending read-ahead
* multishard_combining_reader destroyed with pending read-ahead
does not result in use-after-free or SEGFAULT.

These tests try to do their best to check for correct behaviour with
various BOOST_REQUIRE* checks but they still heavily rely on ASAN to
detect any use-after-free, SEGFAULT or similar errors.
2018-04-30 17:17:45 +03:00
Botond Dénes
cb25afa8bf tests/mutation_reader_test: change recommented smp to 3
Of the test_multishard_combining_reader_reading_empty_table test.
Running this test with smp=3 instead of smp=2 helps detecting additional
read-ahead related memory problems.
2018-04-30 17:17:45 +03:00
Botond Dénes
78266f11c4 mutation_reader_test: fix name of existing multishard reader tests
s/multishard_combined_reader/multishard_combining_reader/
2018-04-30 17:17:44 +03:00
Botond Dénes
ff3982a817 Add unit tests for multishard_combined_reader 2018-04-11 10:03:50 +03:00
Botond Dénes
de4a3c8bdb Add unit tests for foreign_reader 2018-04-11 09:22:49 +03:00
Botond Dénes
341ddd096a Modify unit tests so that they test the dual-limits 2018-03-08 14:12:12 +02:00
Botond Dénes
1259031af3 Use the reader_concurrency_semaphore to limit reader concurrency 2018-03-08 14:12:12 +02:00
Avi Kivity
1dae29b48d test: mutation_reader_test: fix no-timeout case in reader_wrapper
reader_wrapper's _timeout defaults to now(), which means to time
out immediately rather than no timeout.

Fix by switching to a time_point, defaulting to no_timeout, and
provide a compatible constructor (with a duration parameter) for
callers that do want a duration-based timeout.

Tests: mutation_reader_test (debug, release)
Message-Id: <20180305111739.31972-1-avi@scylladb.com>
2018-03-05 12:40:07 +01:00
Paweł Dziepak
ea50806172 tests/mutation_reader: avoid static local lw_shared_ptr
Shared pointer don't like being shared across shards.

Fixes assertion failure in build/debug/tests/mutation_reader_test.
Message-Id: <20180201125017.30259-1-pdziepak@scylladb.com>
2018-02-01 13:53:55 +01:00
Piotr Jastrzebski
7729bc5e7b Remove unused mutation_reader_assertions
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2018-01-24 20:56:48 +01:00
Piotr Jastrzebski
88ca42fa69 dummy_incremental_selector: use flat reader
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2018-01-24 20:56:48 +01:00
José Guilherme Vanz
380bc0aa0d Swap arguments order of mutation constructor
Swap arguments in the mutation constructor keeping the same standard
from the constructor variants. Refs #3084

Signed-off-by: José Guilherme Vanz <guilherme.sft@gmail.com>
Message-Id: <20180120000154.3823-1-guilherme.sft@gmail.com>
2018-01-21 12:58:42 +02:00
Tomasz Grabiec
16e06b5b46 Merge "remove ability to create a non-flat mutation reader" from Piotr
* seastar-dev.git haaawk/flat_reader_clean_up_mutation_source_v3:
  test_range_queries: create flat reader from source
  run_sstable_resharding_test: create flat reader from source
  make_sstable_containing: create flat reader from source
  test_cache_delegates_to_underlying_only_once_multiple_mutation: use
    flat reader
  Migrate materalized views to flat_mutation_reader
  test_can_write_and_read_non_compound_range_tombstone_as_compound: use
    flat reader
  test_writing_combined_stream_with_tombstones_at_the_same_position: use
    flat reader
  Add flat_mutation_reader::peek()
  Add flat_mutation_reader_assertions::produces_range_tombstone
  Accept clustering_row_ranges in
    flat_mutation_reader_assertions::produces
  Add flat_mutation_reader_assertions::produces_eos_or_empty_mutation
  Add flat_mutation_reader_assertions::fast_forward_to overload
  test_query_only_static_row: use flat reader
  Move mutation_rebuilder to header
  test_streamed_mutation_forwarding_is_consistent_with_slicing: use flat
    reader
  test_clustering_slices: use flat reader
  test_streamed_mutation_forwarding_guarantees: use flat reader
  test_streamed_mutation_forwarding_across_range_tombstones: use flat
    reader
  test_streamed_mutation_slicing_returns_only_relevant_tombstones: use
    flat reader
  Add flat_mutation_reader_assertions::is_buffer_full
  test_fast_forwarding_across_partitions_to_empty_range: use flat reader
  Remove unused mutation_source::operator()
  mutation_source: rename make_flat_mutation_reader to make_reader
  Clean up imports in tests
2018-01-19 12:43:50 +01:00
Piotr Jastrzebski
d266eaa01e mutation_source: rename make_flat_mutation_reader to make_reader
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2018-01-19 09:30:12 +01:00
Glauber Costa
378f2ba8e4 mutation_reader_test: adjust sleep time to timeout clock and duration
Raphael recently caught this test failing. I can't really reproduce it,
but it seems to me that it is a timing issue: we execute two different
statements, each one should timeout after 10ms. After 20ms, we make sure
that they both timed out.

They don't (in his system), which is explained by the fact that we are
no longer using high resolution clocks for the timeouts. Expirations for
lowres clocks will only happen at every 10ms, and in the worst case we
will miss twoa.

So the fix I am proposing here is to just account for potential
innacuracies in the clocks and calculations by waiting a bit longer.

Ideally, we would use the manual clock for this. But in this case, this
would mean adding template parameters to pretty much all of the
mutation_reader path.

Currently, not only the test failed, it also had an use-after-free
SIGSEGV. That happens because we give up on the reader while the
timeouts is still to happen.

It is the caller responsibility to ensure the lifetime of the reader is
correct. Dealing with that cleanly would require a cancelation mechanism
that we don't have, so we'll just add an assertion that will fail more
gracefully than the SIGSEGV.

Signed-off-by: Glauber Costa <glauber@scylladb.com>
2018-01-17 17:17:40 +01:00
Glauber Costa
01274774c3 mutation_reader_test: propagate timeouts to fast_forward_to
We are not propagating timeouts to fast_forward_to in the
mutation_reader_test. This is not currently causing any issue, but I
noticed it while chasing one - so let's fix it.

Signed-off-by: Glauber Costa <glauber@scylladb.com>
2018-01-17 17:17:40 +01:00
Raphael S. Carvalho
fd2b4a7eb3 mutation_reader_test: remove schema left over from dummy selector
it now lives in base class, and this one is useless.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
Message-Id: <20180114032943.28228-1-raphaelsc@scylladb.com>
2018-01-14 10:59:48 +02:00
Raphael S. Carvalho
16f8150916 tests: mutation_reader_test: Fix test_combined_reader_slicing_with_overlapping_range_tombstones
Test fails after fa5a26f12d because generated sstable doesn't contain data for the
shard it was created at, so sharding metadata is empty, resulting in exception
added in the aforementioned commit. That's fixed by using the new make_local_key()
to generate data that belongs to current shard.

make_local_keys(), from which make_local_key() is built on top of, will be useful
to make sstable test work again with any smp count.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
Message-Id: <20180114032025.26739-1-raphaelsc@scylladb.com>
2018-01-14 10:59:29 +02:00
Glauber Costa
3c9eeea4cf restricted_mutation_reader: don't pass timeouts through the config structure
This patch enables passing a timeout to the restricted_mutation_reader
through the read path interface -- using fill_buffer and friends. This
will serve as a basis for having per-timeout requests.

The config structure still has a timeout, but that is so far only used
to actually pass the value to the query interface. Once that starts
coming from the storage proxy layer (next patch) we will remove.

The query callers are patched so that we pass the timeout down. We patch
the callers in database.cc, but leave the streaming ones alone. That can
be safely done because the default for the query path is now no_timeout,
and that is what the streaming code wants. So there is no need to
complicate the interface to allow for passing a timeout that we intend
to disable.

Signed-off-by: Glauber Costa <glauber@scylladb.com>
2018-01-12 07:43:21 -05:00
Glauber Costa
5140aaea00 add a timeout to fast forward to
In the last patch, we enabled per-request timeouts, we enable timeouts
in fill_buffer. There are many places, though, in which we
fast_forward_to before we fill_buffer, so in order to make that
effective we need to propagate the timeouts to fast_forward_to as well.

In the same way as fill_buffer, we make the argument optional wherever
possible in the high level callers, making them mandatory in the
implementations.

Signed-off-by: Glauber Costa <glauber@scylladb.com>
2018-01-12 07:43:19 -05:00
Glauber Costa
d965af42b0 add a timeout to fill_buffer
As part of the work to enable per-request timeouts, we enable timeouts
in fill_buffer.

The argument is made optional at the main classes, but mandatory in all
the ::impl versions. This way we'll make sure we didn't forget anything.

At this point we're still mostly passing that information around and
don't have any entity that will act on those timeouts. In the next patch
we will wire that up.

Signed-off-by: Glauber Costa <glauber@scylladb.com>
2018-01-11 12:07:41 -05:00
Raphael S. Carvalho
818830715f Fix potential infinite recursion when combining mutations for leveled compaction
The issue is triggered by compaction of sstables of level higher than 0.

The problem happens when interval map of partitioned sstable set stores
intervals such as follow:
[-9223362900961284625 : -3695961740249769322 ]
(-3695961740249769322 : -3695961103022958562 ]

When selector is called for first interval above, the exclusive lower
bound of the second interval is returned as next token, but the
inclusivess info is not returned.
So reader_selector was returning that there *were* new readers when
the current token was -3695961740249769322 because it was stored in
selector position field as inclusive, but it's actually exclusive.

This false positive was leading to infinite recursion in combined
reader because sstable set's incremental selector itself knew that
there were actually *no* new readers, and therefore *no* progress
could be made.

Fix is to use ring_position in reader_selector, such that
inclusiveness would be respected.
So reader_selector::has_new_readers() won't return false positive
under the conditions described above.

Fixes #2908.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
2018-01-03 16:23:01 -02:00
Tomasz Grabiec
cb34420e1c tests: memtable: Test that combined mutation source is a mutation source 2017-12-22 11:06:34 +01:00
Tomasz Grabiec
7ce52df88b tests: mutation_reader: Test fast forwarding of combined reader with overlapping range tombstones 2017-12-22 11:06:33 +01:00
Tomasz Grabiec
ca6de9e78c tests: mutation_reader: Test combined reader slicing on random mutations 2017-12-22 11:06:33 +01:00
Tomasz Grabiec
52285a9e73 mutation_reader: Use make_combined_reader() to create combined reader
So that we can hide the definition of combined_mutation_reader. It's
also less verbose.
2017-12-21 21:24:11 +01:00
Piotr Jastrzebski
759baa3a11 Migrate test_fast_forwarding_combining_reader to flat reader
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2017-12-21 17:00:43 +01:00
Piotr Jastrzebski
202c562f68 Migrate test_combining_two_partially_overlapping_readers to flat reader
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2017-12-21 17:00:43 +01:00
Piotr Jastrzebski
6c62454076 Migrate test_combining_two_non_overlapping_readers to flat reader
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2017-12-21 17:00:43 +01:00
Piotr Jastrzebski
bef2cf8ed9 Migrate combined_mutation_reader_test to flat reader
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2017-12-21 17:00:43 +01:00
Piotr Jastrzebski
19d4bce624 Migrate test_sm_fast_forwarding_combining_reader to flat reader
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2017-12-21 17:00:43 +01:00
Piotr Jastrzebski
17e6f6b089 Migrate test_combining_one_empty_reader to flat reader
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2017-12-21 17:00:43 +01:00
Piotr Jastrzebski
1f77370d9e Migrate test_combining_two_empty_readers to flat reader
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2017-12-21 17:00:43 +01:00
Piotr Jastrzebski
a702d0ec3f Migrate test_combining_two_readers_with_one_reader_empty to flat reader
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2017-12-21 17:00:43 +01:00
Piotr Jastrzebski
9a5d6bd8af Migrate test_combining_one_reader_with_many_partitions to flat reader
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2017-12-21 17:00:43 +01:00
Piotr Jastrzebski
13551e6f50 Migrate test_combining_two_readers_with_the_same_row to flat reader
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2017-12-21 17:00:43 +01:00
Piotr Jastrzebski
024e01ad9e mutation_source: Add constructors for sources that ignore forwarding
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
2017-12-21 16:59:57 +01:00
Paweł Dziepak
a0a13ceb46 filtering_reader: switch to flat mutation fragment streams 2017-12-13 12:01:03 +00:00
Paweł Dziepak
3bbb3b300d filtering_reader: pass a const dht::decorated_key& to the callback
All users of the filtering reader need only the decorated key of a
partition, but currently the predicate is given a reference to
streamed_mutations which are obsolete now.
2017-12-13 11:57:27 +00:00
Paweł Dziepak
3839bc5d60 mutation_reader: convert restricted reader to flat streams 2017-12-13 10:46:41 +00:00
Avi Kivity
d934ca55a7 Merge "SSTable resharding fixes" from Raphael
"Didn't affect any release. Regression introduced in 301358e.

Fixes #3041"

* 'resharding_fix_v4' of github.com:raphaelsc/scylla:
  tests: add sstable resharding test to test.py
  tests: fix sstable resharding test
  sstables: Fix resharding by not filtering out mutation that belongs to other shard
  db: introduce make_range_sstable_reader
  rename make_range_sstable_reader to make_local_shard_sstable_reader
  db: extract sstable reader creation from incremental_reader_selector
  db: reuse make_range_sstable_reader in make_sstable_reader
2017-12-07 16:42:48 +02:00
Botond Dénes
9fce51f8a0 Add streamed mutation fast-forwarding unit test for the flat combined-reader
Test for the bug fixed by 9661769.

Signed-off-by: Botond Dénes <bdenes@scylladb.com>
Message-Id: <fc917bae8e9c99f026bf7b366e6e9d39faf466af.1512630741.git.bdenes@scylladb.com>
2017-12-07 09:45:12 +02:00