Hekaton error message is slightly misleading

Let’s take a look at the error message that we receive when we do a concurrent update on an In-Memory OLTP (Hekaton) table. I start by opening a connection and running:

begin transaction
 
update CheckingAccount with (snapshot)
set    Balance = 100.00
where  OwnerId = 123;

This update runs fine. Now, after this first statement completes, I open a second connection and run another update against the same table:

update CheckingAccount
set    Balance = 200.00
where  OwnerId = 123;

Since I have an open transaction in the first connection that has updated the same row, I expect the second attempt to fail. It does, and the error message is:

Msg 41302, Level 16, State 110, Line 1
The current transaction attempted to update a record that has been updated since this transaction started. The transaction was aborted.
The statement has been terminated.

The wording of this error message is a bit misleading, however. Clearly the first update did not happen after the second transaction started, particularly given that the second connection had not yet even been established at that time!

Leave a Reply

Your email address will not be published. Required fields are marked *