codenotary / immudb

immudb - immutable database based on zero trust, SQL/Key-Value/Document model, tamperproof, data change history
https://immudb.io
Other
8.54k stars 341 forks source link

tx read conflict error on a concurrent read #1914

Closed NikitaSmall closed 4 months ago

NikitaSmall commented 7 months ago

What happened We have an error of tx read conflict kind. Namely, we have: fetching a different key or an updated one.

We use immugw and send infrequent queries and requests (less than 1 per second) through it (immugw is the only connected client). Example query:

UPDATE transactions SET status = 'completed', externaltxid = '9036a1e2-d321-4d72-9f5b-a13151c68e4d', updatedat = CAST('2024-01-09 09:57:26' AS TIMESTAMP), canceldetails = null, factualamount = '2.69', factualfxrate = '1' WHERE id = 1537;

The ID we use to filter is not used in other queries, so that row should be safe to update.

What you expected to happen The query is to run without trouble.

How to reproduce it (as minimally and precisely as possible) Seems to be a random thing when we have a concurrent situation and multiple threads do the queries.

Environment

immudb: v1.9DOM.2

Additional info (any other context about the problem)

Is there anything you can suggest us to overcome this issue? Thank you in advance!

jeroiraz commented 6 months ago

Probably doing an UPSERT instead of an UPDATE, as only one row is intended to be modified there