mirror of
https://github.com/hanzoai/datastore.git
synced 2026-09-26 13:55:07 +00:00
Use RENAME instead of EXCHANGE for the in-place hits rebuild
The hits datasets are attached in Ordinary databases (default, datasets), and EXCHANGE TABLES is only supported in Atomic databases, so the in-place rebuild of hits_10m_single / hits_100m_single failed with NOT_IMPLEMENTED. Swap the freshly-built table in with a two-table RENAME, which works in Ordinary databases too. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5
parent
f81ca79662
commit
cac097e7c7
@@ -956,7 +956,8 @@ def rebuild_table(port, source, destination):
|
||||
# is what recomputes serialization from the data; a bare OPTIMIZE would
|
||||
# inherit the source parts' serialization, so it cannot replace the insert.
|
||||
# For an in-place rebuild the fresh copy is built under a temporary name and
|
||||
# swapped in atomically with EXCHANGE TABLES.
|
||||
# swapped in with RENAME (the datasets live in Ordinary databases, so
|
||||
# EXCHANGE TABLES is not available).
|
||||
client = _perf_client(port)
|
||||
if Shell.get_output(f'{client} --query "EXISTS TABLE {source}"').strip() != "1":
|
||||
print(f"rebuild_table: source {source} not attached, skipping")
|
||||
@@ -970,8 +971,10 @@ def rebuild_table(port, source, destination):
|
||||
Shell.check(f'{client} --query "INSERT INTO {target} SELECT * FROM {source} SETTINGS {insert_settings}"', strict=True, verbose=True)
|
||||
Shell.check(f'{client} --query "OPTIMIZE TABLE {target} FINAL"', strict=True, verbose=True)
|
||||
if target != destination:
|
||||
Shell.check(f'{client} --query "EXCHANGE TABLES {target} AND {destination}"', strict=True, verbose=True)
|
||||
Shell.check(f'{client} --query "DROP TABLE {target} SYNC"', strict=True, verbose=True)
|
||||
old = f"{destination}_old"
|
||||
Shell.check(f'{client} --query "DROP TABLE IF EXISTS {old} SYNC"', strict=True, verbose=True)
|
||||
Shell.check(f'{client} --query "RENAME TABLE {destination} TO {old}, {target} TO {destination}"', strict=True, verbose=True)
|
||||
Shell.check(f'{client} --query "DROP TABLE {old} SYNC"', strict=True, verbose=True)
|
||||
else:
|
||||
Shell.check(f'{client} --query "DROP TABLE {source} SYNC"', strict=True, verbose=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user