After `insert on conflict replace` record is either missing from the table or gets duplicated
Found in test_insert_on_conflict.
Example with empty result set:
dml = i1.sql(
"""
insert into "t" values (1, 2) on conflict do replace
"""
)
assert dml["row_count"] == 1
data = i1.sql(
"""select * from "t"
"""
)
> assert data["rows"] == [[1, 2]]
E assert [] == [[1, 2]]
E Right contains one more item: [1, 2]
E Full diff:
E - [[1, 2]]
E + []
Full test log: fail1.log
Example with new value being duplicated:
dml = i1.sql(
"""
insert into "t" values (1, 2) on conflict do replace
"""
)
assert dml["row_count"] == 1
data = i1.sql(
"""select * from "t"
"""
)
> assert data["rows"] == [[1, 2]]
E assert [[1, 2], [1, 2]] == [[1, 2]]
E Left contains one more item: [1, 2]
E Full diff:
E - [[1, 2]]
E + [[1, 2], [1, 2]]
Full test log: fail2.log
Unfortunately it doesnt reproduce every time. In total I've got 3 failures, the first one I've got with pytest -n20. Apparently the chance of reproduction is higher when system is under load. Best recipe I've got is to run taskset -c 0 bash -c "while pytest -k insert_on_conflict; do true; done" in one terminal and taskset -c 0 cargo build --release on random project in another. Using something like stress utility should work too but I had no luck with it.