Diesel: "Deadlock detected" CI errors on upsert tests

Created on 24 Mar 2017  路  3Comments  路  Source: diesel-rs/diesel

I've seen some CI run fail recently with

called Result::unwrap() on an Err value: DatabaseError(__Unknown, "deadlock detected")'

For example those:

Two may not be a big enough sampling size, but it seems related to upserts.

help wanted postgres

Most helpful comment

Going to make a lot of coffee and try to solve this tonight

All 3 comments

Going to make a lot of coffee and try to solve this tonight

Ok, after 2 hours battling with my windows VM to install launch link postgresql...

INSERT INTO users (id, name) VALUES(1, 'Sean'), (2, 'Tess')   
CREATE UNIQUE INDEX ON users (name) WHERE name != 'Tess'      

Those are the two queries creating the deadlock

The easy fix is to run tests with RUST_TEST_THREADS=1

Was this page helpful?
0 / 5 - 0 ratings