Merge pull request #5539 from yandex/alter-ttl-fix

Fixed alter modify ttl on ReplicatedMergeTree.
This commit is contained in:
alexey-milovidov 2019-06-05 22:05:17 +03:00 committed by GitHub
commit 42dbb7e881
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 1 deletions

View File

@ -49,7 +49,7 @@ struct ReplicatedMergeTreeTableMetadata
bool ttl_table_changed = false;
String new_ttl_table;
bool empty() const { return !sorting_key_changed && !skip_indices_changed; }
bool empty() const { return !sorting_key_changed && !skip_indices_changed && !ttl_table_changed; }
};
Diff checkAndFindDiff(const ReplicatedMergeTreeTableMetadata & from_zk, bool allow_alter) const;

View File

@ -0,0 +1,3 @@
200
400
CREATE TABLE test.ttl_repl2 (`d` Date, `x` UInt32) ENGINE = ReplicatedMergeTree(\'/clickhouse/tables/test/ttl_repl\', \'2\') PARTITION BY toDayOfMonth(d) ORDER BY x TTL d + toIntervalDay(1) SETTINGS index_granularity = 8192

View File

@ -0,0 +1,25 @@
DROP TABLE IF EXISTS test.ttl_repl1;
DROP TABLE IF EXISTS test.ttl_repl2;
CREATE TABLE test.ttl_repl1(d Date, x UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/test/ttl_repl', '1')
PARTITION BY toDayOfMonth(d) ORDER BY x TTL d + INTERVAL 1 DAY;
CREATE TABLE test.ttl_repl2(d Date, x UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/test/ttl_repl', '2')
PARTITION BY toDayOfMonth(d) ORDER BY x TTL d + INTERVAL 1 DAY;
INSERT INTO TABLE test.ttl_repl1 VALUES (toDate('2000-10-10 00:00:00'), 100);
INSERT INTO TABLE test.ttl_repl1 VALUES (toDate('2100-10-10 00:00:00'), 200);
ALTER TABLE test.ttl_repl1 MODIFY TTL d + INTERVAL 1 DAY;
SYSTEM SYNC REPLICA test.ttl_repl2;
INSERT INTO TABLE test.ttl_repl1 VALUES (toDate('2000-10-10 00:00:00'), 300);
INSERT INTO TABLE test.ttl_repl1 VALUES (toDate('2100-10-10 00:00:00'), 400);
SYSTEM SYNC REPLICA test.ttl_repl2;
SELECT sleep(1) format Null; -- wait for probable merges after inserts
OPTIMIZE TABLE test.ttl_repl2 FINAL;
SELECT x FROM test.ttl_repl2 ORDER BY x;
SHOW CREATE TABLE test.ttl_repl2;