You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At first when writing this change I assumed I would be out to fix issue #429. Turns out that is not an issue as the client wraps this procedure call in a transaction. Thus, no transction is needed within the procedure itself. Here are some improvements, nonetheless.
- Changed @stream_name parameter to NVARCHAR(850) for consistency
- Introduced @Inserted table to capture inserted GlobalPosition values atomically
- Normalized optimistic concurrency errors (2627, 2601) to client-detectable messages
- Thrown error messages still StartsWith 'WrongExpectedVersion' but now also includes the full SQL error text for client tracing
- Removed redundant post-commit queries and error-parsing logic
-- Must BEGIN with "WrongExpectedVersion" for the client detection of OptimisticConcurrencyException
70
+
DECLARE @clientMsg NVARCHAR(4000) =
71
+
N'WrongExpectedVersion: duplicate append for stream '
72
+
+ CAST(@stream_id AS NVARCHAR(20))
73
+
+ N' with expected_version='+ CAST(@expected_version AS NVARCHAR(20))
74
+
+ N'. SQL: '+ @errmsg;
52
75
53
-
-- TODO: There are multiple causes of OptimisticConcurrencyExceptions, but current client code is hard-coded to check for 'WrongExpectedVersion' in message and 50000 as error number.
54
-
SELECT @customErrorMessage = FORMATMESSAGE(N'WrongExpectedVersion, another message has already been written at stream position %s on stream %s.', @streamIdFromError, @streamPositionFromError);
0 commit comments