{question}
How can TRUNCATE TABLE
statements lead to excessive database re-provisioning on the DR cluster?
{question}
{answer}
In SingleStore, the engine performs an ALTER TABLE
for each TRUNCATE TABLE
statement, and each ALTER TABLE
triggers a database snapshot.
A business may have many pipelines or ETL processes that frequently run TRUNCATE TABLE
statements. For example, an ETL process may run 20 TRUNCATE TABLE
statements at startup in preparation for new data loading. That means 20 database snapshots will be taken just by this step.
The number of snapshots kept by a cluster at any given time is defined by the snapshots_to_keep
engine variable, with a default value of 2. As new snapshots are generated, older ones are removed.
Provisioning occurs when a replica database retrieves and replays a snapshot from a source database. Re-provisioning takes place when this process needs to be repeated.
In a replication setup between two clusters, executing TRUNCATE TABLE
statements on the source cluster causes snapshots of that database to be deleted as new ones are created. As a result, when the replica cluster attempts to fetch and replay a snapshot, it might no longer be available on the source cluster.
This triggers database re-provisioning because the requested snapshot is unavailable on the source cluster, necessitating the generation of a new snapshot for the replica.
To avoid frequent re-provisioning, consider:
-
Reducing the number of
TRUNCATE TABLE
operations. -
Evaluating alternative ETL logic that avoids unnecessary
TRUNCATE TABLE
usage.
{answer}