Skip to content

Commit 6c61aea

Browse files
committed
bugfix to ensure resync cannot fail due to table size too large
1 parent daa6658 commit 6c61aea

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

flow/connectors/clickhouse/normalize.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ func (c *ClickHouseConnector) generateCreateTableSQLForNormalizedTable(
270270
if allowNullableKey {
271271
stmtBuilder.WriteString(chinternal.NewCHSettingsString(chVersion, chinternal.SettingAllowNullableKey, "1"))
272272
}
273+
if config.IsResync {
274+
// CREATE OR REPLACE TABLE (used by resync) internally would create a table with name
275+
// <_tmp_replace_*>, atomic swap with the existing table, and then drop the existing table.
276+
// Setting max_table_size_to_drop = 0 ensure the implicit drop does not fail; it can be
277+
// non-empty if a resync is triggered on top of another resync that is still snapshotting.
278+
stmtBuilder.WriteString(chinternal.NewCHSettingsString(chVersion, chinternal.SettingMaxTableSizeToDrop, "0"))
279+
}
273280

274281
if c.Config.Cluster != "" {
275282
fmt.Fprintf(&stmtBuilderDistributed, " ENGINE = Distributed(%s,%s,%s",

0 commit comments

Comments
 (0)