mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-10-21 03:12:34 +00:00
* feat: allow re-enabling WAL after disabling Signed-off-by: dhruvxvaishnav <dhruvvaishnav687@gmail.com> * test: regenerate skip_wal sqlness result The previous commit changed tests/cases/standalone/common/skip_wal.sql without regenerating the matching .result, so every Sqlness suite failed on the mismatch. tests/cases/distributed/common is a symlink to standalone/common, so the single stale file accounted for all five failing variants. Regenerated from a real run. The recorded output now covers the cases the .sql added: * A table created with skip_wal = 'true' has no real WAL provider, so enabling WAL is refused with Unsupported rather than the previous InvalidArguments. * A RaftEngine-backed table accepts the true -> false transition, and repeating it is a no-op. * SHOW CREATE TABLE reports skip_wal = 'false' after the transition, including after a restart. * A row written while WAL was skipped is absent after restart, while a row written after WAL was restored survives. Verified locally with nothing else running on the machine: sqlness skip_wal passes in both the standalone and distributed environments, and the regenerated file is byte-identical to the output of an independent earlier run. Signed-off-by: dhruvxvaishnav <dhruvvaishnav687@gmail.com> * test: strengthen skip_wal provider coverage Signed-off-by: dhruvxvaishnav <dhruvvaishnav687@gmail.com> * Fix WAL provider handling during re-enable Signed-off-by: dhruvxvaishnav <dhruvvaishnav687@gmail.com> * Refactor WAL provider check Signed-off-by: dhruvxvaishnav <dhruvvaishnav687@gmail.com> --------- Signed-off-by: dhruvxvaishnav <dhruvvaishnav687@gmail.com>
189 lines
6.9 KiB
Plaintext
189 lines
6.9 KiB
Plaintext
CREATE TABLE system_metrics (
|
|
host STRING,
|
|
idc STRING,
|
|
cpu_util DOUBLE,
|
|
memory_util DOUBLE,
|
|
disk_util DOUBLE,
|
|
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP(),
|
|
PRIMARY KEY(host, idc),
|
|
TIME INDEX(ts)
|
|
) WITH (skip_wal = "true");
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO system_metrics
|
|
VALUES
|
|
("host1", "idc_a", 11.8, 10.3, 10.3, 1667446797450),
|
|
("host2", "idc_a", 80.0, 70.3, 90.0, 1667446797450),
|
|
("host1", "idc_b", 50.0, 66.7, 40.6, 1667446797450);
|
|
|
|
Affected Rows: 3
|
|
|
|
-- SQLNESS ARG restart=true
|
|
SELECT * FROM system_metrics;
|
|
|
|
+------+-----+----------+-------------+-----------+----+
|
|
| host | idc | cpu_util | memory_util | disk_util | ts |
|
|
+------+-----+----------+-------------+-----------+----+
|
|
+------+-----+----------+-------------+-----------+----+
|
|
|
|
INSERT INTO system_metrics
|
|
VALUES
|
|
("host1", "idc_a", 11.8, 10.3, 10.3, 1667446797450),
|
|
("host2", "idc_a", 80.0, 70.3, 90.0, 1667446797450),
|
|
("host1", "idc_b", 50.0, 66.7, 40.6, 1667446797450);
|
|
|
|
Affected Rows: 3
|
|
|
|
ADMIN flush_table('system_metrics');
|
|
|
|
+-------------------------------------+
|
|
| ADMIN flush_table('system_metrics') |
|
|
+-------------------------------------+
|
|
| 0 |
|
|
+-------------------------------------+
|
|
|
|
-- SQLNESS ARG restart=true
|
|
SELECT * FROM system_metrics;
|
|
|
|
+-------+-------+----------+-------------+-----------+-------------------------+
|
|
| host | idc | cpu_util | memory_util | disk_util | ts |
|
|
+-------+-------+----------+-------------+-----------+-------------------------+
|
|
| host1 | idc_a | 11.8 | 10.3 | 10.3 | 2022-11-03T03:39:57.450 |
|
|
| host1 | idc_b | 50.0 | 66.7 | 40.6 | 2022-11-03T03:39:57.450 |
|
|
| host2 | idc_a | 80.0 | 70.3 | 90.0 | 2022-11-03T03:39:57.450 |
|
|
+-------+-------+----------+-------------+-----------+-------------------------+
|
|
|
|
-- A table created without a real WAL provider cannot enable WAL later.
|
|
ALTER TABLE system_metrics SET 'skip_wal' = 'false';
|
|
|
|
Error: 1001(Unsupported), Unsupported operation setting skip_wal = 'false' without an existing WAL provider
|
|
|
|
DROP TABLE system_metrics;
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE alter_skip_wal (
|
|
host STRING,
|
|
val DOUBLE,
|
|
ts TIMESTAMP,
|
|
PRIMARY KEY(host),
|
|
TIME INDEX(ts)
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO alter_skip_wal VALUES ('host1', 1, 1000);
|
|
|
|
Affected Rows: 1
|
|
|
|
ALTER TABLE alter_skip_wal SET 'skip_wal' = 'true';
|
|
|
|
Affected Rows: 0
|
|
|
|
SHOW CREATE TABLE alter_skip_wal;
|
|
|
|
+----------------+-----------------------------------------------+
|
|
| Table | Create Table |
|
|
+----------------+-----------------------------------------------+
|
|
| alter_skip_wal | CREATE TABLE IF NOT EXISTS "alter_skip_wal" ( |
|
|
| | "host" STRING NULL, |
|
|
| | "val" DOUBLE NULL, |
|
|
| | "ts" TIMESTAMP(3) NOT NULL, |
|
|
| | TIME INDEX ("ts"), |
|
|
| | PRIMARY KEY ("host") |
|
|
| | ) |
|
|
| | |
|
|
| | ENGINE=mito |
|
|
| | WITH( |
|
|
| | skip_wal = 'true' |
|
|
| | ) |
|
|
+----------------+-----------------------------------------------+
|
|
|
|
-- This row is intentionally not written to WAL.
|
|
INSERT INTO alter_skip_wal VALUES ('host2', 2, 2000);
|
|
|
|
Affected Rows: 1
|
|
|
|
ALTER TABLE alter_skip_wal SET 'skip_wal' = 'false';
|
|
|
|
Affected Rows: 0
|
|
|
|
SHOW CREATE TABLE alter_skip_wal;
|
|
|
|
+----------------+-----------------------------------------------+
|
|
| Table | Create Table |
|
|
+----------------+-----------------------------------------------+
|
|
| alter_skip_wal | CREATE TABLE IF NOT EXISTS "alter_skip_wal" ( |
|
|
| | "host" STRING NULL, |
|
|
| | "val" DOUBLE NULL, |
|
|
| | "ts" TIMESTAMP(3) NOT NULL, |
|
|
| | TIME INDEX ("ts"), |
|
|
| | PRIMARY KEY ("host") |
|
|
| | ) |
|
|
| | |
|
|
| | ENGINE=mito |
|
|
| | WITH( |
|
|
| | skip_wal = 'false' |
|
|
| | ) |
|
|
+----------------+-----------------------------------------------+
|
|
|
|
-- Repeating the transition is idempotent.
|
|
ALTER TABLE alter_skip_wal SET 'skip_wal' = 'false';
|
|
|
|
Affected Rows: 0
|
|
|
|
ALTER TABLE alter_skip_wal UNSET 'skip_wal';
|
|
|
|
Error: 1004(InvalidArguments), Invalid unset table option request: Invalid set region option request, key: skip_wal
|
|
|
|
-- This row uses the restored WAL provider.
|
|
INSERT INTO alter_skip_wal VALUES ('host3', 3, 3000);
|
|
|
|
Affected Rows: 1
|
|
|
|
SELECT * FROM alter_skip_wal ORDER BY ts;
|
|
|
|
+-------+-----+---------------------+
|
|
| host | val | ts |
|
|
+-------+-----+---------------------+
|
|
| host1 | 1.0 | 1970-01-01T00:00:01 |
|
|
| host2 | 2.0 | 1970-01-01T00:00:02 |
|
|
| host3 | 3.0 | 1970-01-01T00:00:03 |
|
|
+-------+-----+---------------------+
|
|
|
|
-- Re-enabling WAL does not retroactively write the skipped row to WAL.
|
|
-- SQLNESS ARG restart=true
|
|
SHOW CREATE TABLE alter_skip_wal;
|
|
|
|
+----------------+-----------------------------------------------+
|
|
| Table | Create Table |
|
|
+----------------+-----------------------------------------------+
|
|
| alter_skip_wal | CREATE TABLE IF NOT EXISTS "alter_skip_wal" ( |
|
|
| | "host" STRING NULL, |
|
|
| | "val" DOUBLE NULL, |
|
|
| | "ts" TIMESTAMP(3) NOT NULL, |
|
|
| | TIME INDEX ("ts"), |
|
|
| | PRIMARY KEY ("host") |
|
|
| | ) |
|
|
| | |
|
|
| | ENGINE=mito |
|
|
| | WITH( |
|
|
| | skip_wal = 'false' |
|
|
| | ) |
|
|
+----------------+-----------------------------------------------+
|
|
|
|
SELECT * FROM alter_skip_wal ORDER BY ts;
|
|
|
|
+-------+-----+---------------------+
|
|
| host | val | ts |
|
|
+-------+-----+---------------------+
|
|
| host1 | 1.0 | 1970-01-01T00:00:01 |
|
|
| host3 | 3.0 | 1970-01-01T00:00:03 |
|
|
+-------+-----+---------------------+
|
|
|
|
DROP TABLE alter_skip_wal;
|
|
|
|
Affected Rows: 0
|
|
|