Closed nhajratw closed 1 year ago
MSSQL truncates transaction's name automatically if it exceed 32 characters, so we can simply show warning instead of throwing exception.
agreed -- that could work as well. The reason i suggested truncating the beginning is that if you have two different methods:
com.company.name.here.SomeServiceClass.theMethod1
com.company.name.here.SomeServiceClass.theMethod2
Then truncating the beginning would give both transactions the same name of com.company.name.here.SomeServic
, which would make it impossible to differentiate when looking at logs.
Happy to include a truncation. We might not log this event but rather silently accept the fact that we're truncating the transaction name.
The issue originates from a default behavior where you (do/can) not specify the transaction name. Hence we can just remove the obstacle that causes transactions to fail. A natural consequence of truncating is information loss. If the data beforehand would be correct, then we would not run into that issue.
Bug Report
Current Behavior
When using r2dbc-mssql via spring-r2dbc with
@Transactional
, the name of the transaction is the FQ class name. This cannot be overridden:https://docs.spring.io/spring-framework/docs/current/reference/html/data-access.html#transaction-declarative-attransactional-settings
r2dbc-mssql is correctly limiting the transaction name to 32 characters per https://learn.microsoft.com/en-us/sql/t-sql/language-elements/begin-transaction-transact-sql?view=sql-server-ver16#arguments
As such, we end up with this exception:
Steps to reproduce
Any class like the following will reproduce the problem:
the transaction name here will be
com.company.name.here.SomeServiceClass.theMethod
which is > 32 chars an errors.Possible Solution
Truncate the beginning of the name so that you end up with the last 32 characters (excluding punctuation): i.e.
here.SomeServiceClass.theMethod