Botond Dénes
5ebe2c28d1
db/view: view_update_generator: re-balance wait/signal on the register semaphore
The view update generator has a semaphore to limit concurrency. This
semaphore is waited on in `register_staging_sstable()` and later the
unit is returned after the sstable is processed in the loop inside
`start()`.
This was broken by 4e64002, which changed the loop inside `start()` to
process sstables in per table batches, however didn't change the
`signal()` call to return the amount of units according to the number of
sstables processed. This can cause the semaphore units to dry up, as the
loop can process multiple sstables per table but return just a single
unit. This can also block callers of `register_staging_sstable()`
indefinitely as some waiters will never be released as under the right
circumstances the units on the semaphore can permanently go below 0.
In addition to this, 4e64002 introduced another bug: table entries from
the `_sstables_with_tables` are never removed, so they are processed
every turn. If the sstable list is empty, there won't be any update
generated but due to the unconditional `signal()` described above, this
can cause the units on the semaphore to grow to infinity, allowing
future staging sstables producers to register a huge amount of sstables,
causing memory problems due to the amount of sstable readers that have
to be opened (#6603, #6707).
Both outcomes are equally bad. This patch fixes both issues and modifies
the `test_view_update_generator` unit test to reproduce them and hence
to verify that this doesn't happen in the future.
Fixes: #6774
Refs: #6707
Refs: #6603
Tests: unit(dev)
Signed-off-by: Botond Dénes <bdenes@scylladb.com>
Message-Id: <20200706135108.116134-1-bdenes@scylladb.com>
2020-07-07 08:53:00 +02:00
..
2020-06-24 17:22:29 +03:00
2020-06-22 15:09:04 +03:00
2019-10-25 12:04:44 +02:00
2020-07-07 08:53:00 +02:00
2020-05-18 16:05:23 +02:00
2020-02-10 20:54:32 +03:00
2020-06-18 09:37:18 -04:00
2020-06-18 09:37:18 -04:00
2019-04-02 19:08:25 +03:00
2020-04-15 12:20:30 +02:00
2020-04-15 12:20:30 +02:00
2019-02-14 14:52:51 +02:00
2019-12-11 10:44:40 -08:00
2020-03-23 09:29:45 +02:00
2020-03-10 12:51:02 +02:00
2020-03-10 12:51:02 +02:00
2018-12-10 21:22:56 +02:00
2020-03-05 16:09:44 +01:00
2018-07-26 16:54:58 +01:00
2017-06-13 09:57:14 +03:00
2020-02-04 21:15:44 -08:00
2020-03-03 11:34:00 +01:00
2020-07-03 10:27:23 +02:00
2020-03-23 09:29:45 +02:00
2020-02-12 16:44:12 +03:00
2018-11-26 18:49:08 +01:00
2020-03-15 10:25:20 +01:00
2020-07-03 10:27:23 +02:00
2020-03-15 10:25:20 +01:00
2020-03-27 11:40:03 +03:00
2020-03-23 09:29:45 +02:00
2020-06-26 20:28:25 +03:00
2020-06-26 20:26:15 +03:00
2020-05-25 14:17:31 +03:00
2020-05-25 14:17:28 +03:00
2020-06-05 09:59:16 +02:00
2020-06-05 09:59:16 +02:00
2020-04-05 12:46:04 +03:00
2020-06-10 15:49:51 +03:00
2020-05-25 14:17:31 +03:00
2018-12-19 22:38:29 +00:00
2020-03-23 09:29:45 +02:00