File: test_stress_update_issue_19688.test

package info (click to toggle)
duckdb 1.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 299,196 kB
  • sloc: cpp: 865,414; ansic: 57,292; python: 18,871; sql: 12,663; lisp: 11,751; yacc: 7,412; lex: 1,682; sh: 747; makefile: 558
file content (53 lines) | stat: -rw-r--r-- 1,224 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# name: test/sql/update/test_stress_update_issue_19688.test
# description: Concurrent stress test: UPDATE/DELETE/INSERT
# group: [update]

statement ok
DROP TABLE IF EXISTS test_stress_update_issue_19688

statement ok
CREATE TABLE test_stress_update_issue_19688 (
    id INTEGER,
    val INTEGER
)

# Insert 1000 initial rows
statement ok
INSERT INTO test_stress_update_issue_19688 SELECT range AS id, range * 1000 AS val FROM range(1000)

# Verify initial count
query I
SELECT COUNT(*) FROM test_stress_update_issue_19688
----
1000

# Launch 8 concurrent workers to perform UPDATE/DELETE/INSERT operations on the same rows
concurrentloop threadid 0 8

# Each worker operates on all 1000 rows
loop i 0 1000

statement maybe
UPDATE test_stress_update_issue_19688 SET val = (${threadid} * 10000 + ${i}) WHERE id = ${i}
----
TransactionContext Error

statement maybe
DELETE FROM test_stress_update_issue_19688 WHERE id = ${i}
----
TransactionContext Error

statement maybe
INSERT INTO test_stress_update_issue_19688 VALUES (${i}, ${threadid} * 10000 + ${i})
----
TransactionContext Error

endloop

endloop

# Verify all IDs from 0-999 are present
query I
SELECT COUNT(DISTINCT id) FROM test_stress_update_issue_19688
----
1000