mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-30 03:30:49 +00:00
This series refactors `table::snapshot` and moves the responsibility
to flush the table before taking the snapshot to the caller.
`flush_on_all` and `snapshot_on_all` helpers are added to replica::database
(by making it a peering_sharded_service) and upper layers,
including api and snapshot-ctl now call it instead of calling cf.snapshot directly.
With that, error are handed in table::snapshot and propagated
back to the callers.
Failure to allocate the `snapshot_manager` object is fatal,
similar to failure to allocate a continuation, since we can't
coordinate across the shards without it.
Test: unit(dev), rest_api(debug)
* github.com:scylladb/scylla:
table: snapshot: handle errors
table: snapshot: get rid of skip_flush param
database: truncate: skip flush when taking snapshot
test: rest_api: storage_service: verify_snapshot_details: add truncate
database: snapshot_on_all: flush before snapshot if needed
table: make snapshot method private
database: add snapshot_on_all
snapshot-ctl: run_snapshot_modify_operation: reject views and secondary index using the schema
snapshot-ctl: refactor and coroutinize take_snapshot / take_column_family_snapshot
api: storage_service: increase visibility of snapshot ops in the log
api: storage_service: coroutinize take_snapshot and del_snapshot
api: storage_service: take_snapshot: improve api help messages
test: rest_api: storage_service: add test_storage_service_snapshot
database: add flush_on_all variants
test: rest_api: add test_storage_service_flush
(cherry picked from commit 2c39c4c284)
Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
Closes #10975
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
import time
|
|
|
|
from contextlib import contextmanager
|
|
|
|
# A utility function for creating a new temporary snapshot.
|
|
# If no keyspaces are given, a snapshot is taken over all keyspaces and tables.
|
|
# If no tables are given, a snapshot is taken over all tables in the keyspace.
|
|
# If no tag is given, a unique tag will be computed using the current time, in milliseconds.
|
|
# It can be used in a "with", as:
|
|
# with new_test_snapshot(cql, tag, keyspace, [table(s)]) as snapshot:
|
|
# This is not a fixture - see those in conftest.py.
|
|
@contextmanager
|
|
def new_test_snapshot(rest_api, keyspaces=[], tables=[], tag=""):
|
|
if not tag:
|
|
tag = f"test_snapshot_{int(time.time() * 1000)}"
|
|
params = { "tag": tag }
|
|
if type(keyspaces) is str:
|
|
params["kn"] = keyspaces
|
|
else:
|
|
params["kn"] = ",".join(keyspaces)
|
|
if tables:
|
|
if type(tables) is str:
|
|
params["cf"] = tables
|
|
else:
|
|
params["cf"] = ",".join(tables)
|
|
resp = rest_api.send("POST", "storage_service/snapshots", params)
|
|
resp.raise_for_status()
|
|
try:
|
|
yield tag
|
|
finally:
|
|
resp = rest_api.send("DELETE", "storage_service/snapshots", params)
|
|
resp.raise_for_status()
|