I accidentally found zombie transaction
is mentioned in SqlTransaction
code. So, what is zombie transaction?
A zombie transaction is a transaction that cannot be committed (due to an unrecoverable error) but is still open.
CREATE TABLE mytable (id INT NOT NULL PRIMARY KEY)
SET XACT_ABORT ON;
BEGIN TRY
BEGIN TRANSACTION
INSERT
INTO mytable
VALUES (1)
INSERT
INTO mytable
VALUES (1)
COMMIT
END TRY
BEGIN CATCH
PRINT XACT_STATE()
SELECT *
FROM mytable
ROLLBACK;
END CATCH
SELECT *
FROM mytable
Here, the second INSERT
renders the transaction zombie.
It cannot write anymore and should be rolled back, but you can still read in its scope (the innermost SELECT
returns a record; the outermost does not).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With