Subject Re: [firebird-support] Error during delete statement.
Author Vlad Khorsun
""Calin Pirtea"" ...
> Hi All,
>
> ISC ERROR CODE:335544382
>
> ISC ERROR MESSAGE:
> cannot update erased record
>
> I get this error during a delete statement and I do not understand what
> happens to trigger it.
>
> The error I usually get (and expect) is:
> ISC ERROR CODE:335544345
>
> ISC ERROR MESSAGE:
> lock conflict on no wait transaction
> deadlock
> update conflicts with concurrent update
> concurrent transaction number is 146304
>
> This is not a production error but an extreme test case that performs a
> lot of random inserts, selects and deletes.
>
> Can someone please explain if the top error is normal?


When record is about to be updated (or deleted) Firebird first reads it and
checks its transaction number against current transaction and its isolation mode.
At this stage "update conflict" error message is possible.

If current record version was created by currently committed transaction and
current transaction also see it as committed then current transaction allowed to
proceed.

Than backversion is created and stored somewhere and new version is prepared
in-memory.

Than current version is fetched again to be replaced by just created new version.

In the mean time another transaction could delete our record and commit. More,
if our transaction is read-committed it don't prevent garbage collection from physically
deleting our record. So, current version can't be fetched as it is not exists anymore.
In this case "cannot update erased record" error is raised.

For application it is almost the same as "update conflicts with concurrent update".

Regards,
Vlad