-
Notifications
You must be signed in to change notification settings - Fork 481
Document ART index limitation with concurrent transactions and deletes #5724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,4 +108,25 @@ Violates foreign key constraint because key "id: 1" is still referenced by a for | |
| ``` | ||
|
|
||
| The reason for this is because DuckDB does not yet support “looking ahead”. | ||
| During the `INSERT`, it is unaware it will reinsert the foreign key value as part of the `UPDATE` rewrite. | ||
| During the `INSERT`, it is unaware it will reinsert the foreign key value as part of the `UPDATE` rewrite. | ||
|
|
||
| ### Constraint Checking After Delete With Concurrent Transactions | ||
|
|
||
| When a delete is committed on a table with an ART index, data can only be removed from the index when no further transactions exist that refer to the deleted entry. This means if you perform a delete transaction, a subsequent transaction which inserts a record with the same key as the deleted record can fail with a constraint error if there is a concurrent transaction referencing the deleted record. Pseudocode to demonstrate: | ||
|
||
|
|
||
| ``` | ||
szarnyasg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Assume "someTable" is a table with an ART index preventing duplicates | ||
|
||
| tx1 = duckdbTxStart() | ||
| someRecord = duckdb(tx1, "select * from someTable using sample 1 rows") | ||
|
|
||
| tx2 = duckdbTxStart() | ||
| duckdbDelete(tx2, someRecord) | ||
| duckdbTxCommit(tx2) | ||
|
|
||
| // At this point someRecord is deleted, but the ART index is not updated, so the following would fail with a constraint error: | ||
| // tx3 = duckdbTxStart() | ||
| // duckdbInsert(tx3, someRecord) | ||
| // duckdbTxCommit(tx3) | ||
|
|
||
| duckdbTxCommit(tx1) // Following this, the above insert would succeed because the ART index was allowed to update | ||
| ``` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
committed on a table with an index(happens for all our indexes, also those in extensions). There, we just don't notice, as we don't use them for constraint checking.