I accidentally found zombie transaction
is mentioned in SqlTransaction
code. So, what is zombie transaction?
views:
62answers:
1
+4
A:
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).
Quassnoi
2010-10-28 13:42:42
And you need a machete or shotgun to get rid of it!...Man, I love I.T. work. 80)
Keng
2010-10-28 13:47:09
Do you prefer an axe or a baseball bat?
Mitch Wheat
2010-10-28 14:20:42