Skip to content

Commit 1599c02

Browse files
committed
chore(mssql): enable XACT_ABORT for all stored procedures used by Eventuous
Added SET XACT_ABORT ON to all SQL stored procedures invoked through GetStoredProcCommand() to ensure atomic rollback behavior when the client transaction encounters an error. This prevents partial commits and inconsistent transactional states during event append and stream operations. Related to issue #429
1 parent f84fbc4 commit 1599c02

File tree

7 files changed

+7
-0
lines changed

7 files changed

+7
-0
lines changed

src/SqlServer/src/Eventuous.SqlServer/Scripts/2_AppendEvents.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CREATE OR ALTER PROCEDURE __schema__.append_events
66
AS
77
BEGIN
88
SET NOCOUNT ON;
9+
SET XACT_ABORT ON;
910

1011
-- Note: This procedure is wrapped in a transaction by the caller. This explains why there is no explicit transaction here within the procedure.
1112

src/SqlServer/src/Eventuous.SqlServer/Scripts/3_CheckStream.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CREATE OR ALTER PROCEDURE __schema__.check_stream
66
AS
77
BEGIN
88
SET NOCOUNT ON;
9+
SET XACT_ABORT ON;
910

1011
DECLARE @customErrorMessage NVARCHAR(200);
1112

src/SqlServer/src/Eventuous.SqlServer/Scripts/4_ReadAllForwards.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CREATE OR ALTER PROCEDURE __schema__.read_all_forwards
44
AS
55
BEGIN
66
SET NOCOUNT ON;
7+
SET XACT_ABORT ON;
78

89
SELECT TOP (@count)
910
m.MessageId,

src/SqlServer/src/Eventuous.SqlServer/Scripts/5_ReadStreamBackwards.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CREATE OR ALTER PROCEDURE __schema__.read_stream_backwards
55
AS
66
BEGIN
77
SET NOCOUNT ON;
8+
SET XACT_ABORT ON;
89

910
DECLARE
1011
@current_version INT,

src/SqlServer/src/Eventuous.SqlServer/Scripts/6_ReadStreamForwards.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CREATE OR ALTER PROCEDURE __schema__.read_stream_forwards
55
AS
66
BEGIN
77
SET NOCOUNT ON;
8+
SET XACT_ABORT ON;
89

910
DECLARE
1011
@current_version INT,

src/SqlServer/src/Eventuous.SqlServer/Scripts/7_ReadStreamSub.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CREATE OR ALTER PROCEDURE __schema__.read_stream_sub
66
AS
77
BEGIN
88
SET NOCOUNT ON;
9+
SET XACT_ABORT ON;
910

1011
SELECT TOP (@count)
1112
MessageId,

src/SqlServer/src/Eventuous.SqlServer/Scripts/8_TruncateStream.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CREATE OR ALTER PROCEDURE __schema__.truncate_stream
55
AS
66
BEGIN
77
SET NOCOUNT ON;
8+
SET XACT_ABORT ON;
89

910
DECLARE
1011
@current_version INT,

0 commit comments

Comments
 (0)