mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-16 10:33:27 +08:00
Don't abort additional INSERTs when hitting first conflict
When an INSERT with ON CONFLICT DO NOTHING hits the first conflicts it would abort additional INSERTS following the INSERT triggering the DO NOTHING clause leading to missed INSERTs. Fixes #7672
This commit is contained in:
parent
89062cb94b
commit
41b141fae3
2
.unreleased/pr_7673
Normal file
2
.unreleased/pr_7673
Normal file
@ -0,0 +1,2 @@
|
||||
Fixes: #7673 Don't abort additional INSERTs when hitting first conflict
|
||||
Thanks: @bjornuppeke for reporting a problem with INSERT INTO ... ON CONFLICT DO NOTHING on compressed chunks
|
@ -728,7 +728,7 @@ ExecModifyTable(CustomScanState *cs_node, PlanState *pstate)
|
||||
cds->skip_current_tuple = false;
|
||||
if (node->ps.instrument)
|
||||
node->ps.instrument->ntuples2++;
|
||||
return NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* No more tuples to process? */
|
||||
|
@ -748,3 +748,33 @@ VALUES
|
||||
(41, 1609478100000, 'val1')
|
||||
ON CONFLICT DO NOTHING;
|
||||
INFO: Using index scan with scan keys: index 1, heap 4, memory 2.
|
||||
INFO: Using index scan with scan keys: index 1, heap 4, memory 2.
|
||||
RESET timescaledb.debug_compression_path_info;
|
||||
-- gh issue #7672
|
||||
-- check additional INSERTS after hitting ON CONFLICT clause still go through
|
||||
CREATE TABLE test_i7672(time timestamptz, device text, primary key(time,device));
|
||||
SELECT create_hypertable('test_i7672', 'time');
|
||||
create_hypertable
|
||||
--------------------------
|
||||
(13,public,test_i7672,t)
|
||||
(1 row)
|
||||
|
||||
ALTER TABLE test_i7672 SET (timescaledb.compress, timescaledb.compress_orderby='time DESC', timescaledb.compress_segmentby='device');
|
||||
INSERT INTO test_i7672 VALUES ('2025-01-01','d1');
|
||||
SELECT count(*) FROM (SELECT compress_chunk(show_chunks('test_i7672'))) c;
|
||||
count
|
||||
-------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
INSERT INTO test_i7672 VALUES
|
||||
('2025-01-01','d1'),
|
||||
('2025-01-01','d2')
|
||||
ON CONFLICT DO NOTHING;
|
||||
SELECT * FROM test_i7672 t ORDER BY t;
|
||||
time | device
|
||||
------------------------------+--------
|
||||
Wed Jan 01 00:00:00 2025 PST | d1
|
||||
Wed Jan 01 00:00:00 2025 PST | d2
|
||||
(2 rows)
|
||||
|
||||
|
@ -518,3 +518,21 @@ VALUES
|
||||
(41, 1609478100000, 'val1')
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
RESET timescaledb.debug_compression_path_info;
|
||||
|
||||
-- gh issue #7672
|
||||
-- check additional INSERTS after hitting ON CONFLICT clause still go through
|
||||
CREATE TABLE test_i7672(time timestamptz, device text, primary key(time,device));
|
||||
SELECT create_hypertable('test_i7672', 'time');
|
||||
ALTER TABLE test_i7672 SET (timescaledb.compress, timescaledb.compress_orderby='time DESC', timescaledb.compress_segmentby='device');
|
||||
INSERT INTO test_i7672 VALUES ('2025-01-01','d1');
|
||||
|
||||
SELECT count(*) FROM (SELECT compress_chunk(show_chunks('test_i7672'))) c;
|
||||
|
||||
INSERT INTO test_i7672 VALUES
|
||||
('2025-01-01','d1'),
|
||||
('2025-01-01','d2')
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
SELECT * FROM test_i7672 t ORDER BY t;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user