Skip to content

Wrong logic for InsertOrUpdate #2970

Open
@FranckPachot

Description

It seems that InsertOrUpdate generates a command with two statements:

[info] 2024-06-15T18:34:30.527 [-2] DEBUG slick.jdbc.JdbcBackend.statement Preparing statement: update "test" set "value"=? where "id"=?; insert into "test" ("id","value") select ?,? where not exists (select 1 from "test" where "id"=?)

This will result in lost updates when running in Read Committed (the default in many databases) because another transaction can insert the row between the two statements. It will be ignored by the update that happens before and ignored by the insert that happens later. Because Read Committed on Multi-Version Concurrency Control sets a different read time for each statement.

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions