You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Compressed DELETE deletes the rows it shouldn't (data loss)Β #10129
-- Direct batch delete on compressed hypertable silently deletes rows
-- when segmentby predicate is <> ANY(NULL::array).
CREATE TABLE trade_ticks (
ts timestamptz NOT NULL,
exchange int,
price int
);
SELECT create_hypertable('trade_ticks', 'ts',
chunk_time_interval => interval '1 day');
ALTER TABLE trade_ticks SET (
timescaledb.compress,
timescaledb.compress_segmentby = 'exchange',
timescaledb.compress_orderby = 'ts'
);
INSERT INTO trade_ticks
SELECT '2024-01-01'::timestamptz + (g * interval '5 minutes'),
g % 4, g
FROM generate_series(0, 287) g;
SELECT compress_chunk(c) FROM show_chunks('trade_ticks') c;
-- Predicate matches zero rows:
SELECT count(*) AS matching_rows
FROM trade_ticks
WHERE exchange <> ANY (NULL::int[]);
-- matching_rows = 0
-- Baseline: optimization off, correct result.
BEGIN;
SET LOCAL timescaledb.enable_compressed_direct_batch_delete = off;
DELETE FROM trade_ticks WHERE exchange <> ANY (NULL::int[]);
-- DELETE 0
SELECT count(*) AS rows_baseline FROM trade_ticks;
-- rows_baseline = 288
ROLLBACK;
-- Bug: direct batch delete silently removes rows.
DELETE FROM trade_ticks WHERE exchange <> ANY (NULL::int[]);
-- DELETE 216, expected DELETE 0
SELECT count(*) AS rows_after FROM trade_ticks;
-- rows_after = 72, expected 288
SELECT exchange, count(*) FROM trade_ticks GROUP BY exchange ORDER BY exchange;
-- only exchange=0 survives
Looks like this is our favorite mechanism: direct batch delete tries to guess which conditions were pushed down to compressed scan instead of using the ground truth, and guesses wrong.
Activity
Bugfix for direct delete with NULL array predicates
Bugfix for direct delete with NULL array predicates
Bugfix for direct delete with NULL array predicates
Bugfix for direct delete with NULL array predicates
Bugfix for direct delete with NULL array predicates
Bugfix for direct delete with NULL array predicates
Bugfix for direct delete with NULL array predicates
Bugfix for direct delete with NULL array predicates
Bugfix for direct delete with NULL array predicates
Bugfix for direct delete with NULL array predicates
Bugfix for direct delete with NULL array predicates
Bugfix for direct delete with NULL array predicates
Release 2.28.3