File tree 1 file changed +9
-8
lines changed 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -181,13 +181,6 @@ func (c *XAConn) createNewTxOnExecIfNeed(ctx context.Context, f func() (types.Ex
181
181
err error
182
182
)
183
183
184
- currentAutoCommit := c .autoCommit
185
- if c .txCtx .TransactionMode != types .Local && tm .IsGlobalTx (ctx ) && c .autoCommit {
186
- tx , err = c .BeginTx (ctx , driver.TxOptions {Isolation : driver .IsolationLevel (gosql .LevelDefault )})
187
- if err != nil {
188
- return nil , err
189
- }
190
- }
191
184
defer func () {
192
185
recoverErr := recover ()
193
186
if err != nil || recoverErr != nil {
@@ -201,6 +194,14 @@ func (c *XAConn) createNewTxOnExecIfNeed(ctx context.Context, f func() (types.Ex
201
194
}
202
195
}()
203
196
197
+ currentAutoCommit := c .autoCommit
198
+ if c .txCtx .TransactionMode != types .Local && tm .IsGlobalTx (ctx ) && c .autoCommit {
199
+ tx , err = c .BeginTx (ctx , driver.TxOptions {Isolation : driver .IsolationLevel (gosql .LevelDefault )})
200
+ if err != nil {
201
+ return nil , err
202
+ }
203
+ }
204
+
204
205
// execute SQL
205
206
ret , err := f ()
206
207
if err != nil {
@@ -212,7 +213,7 @@ func (c *XAConn) createNewTxOnExecIfNeed(ctx context.Context, f func() (types.Ex
212
213
}
213
214
214
215
if tx != nil && currentAutoCommit {
215
- if err : = c .Commit (ctx ); err != nil {
216
+ if err = c .Commit (ctx ); err != nil {
216
217
log .Errorf ("xa connection proxy commit failure xid:%s, err:%v" , c .txCtx .XID , err )
217
218
// XA End & Rollback
218
219
if err := c .Rollback (ctx ); err != nil {
You can’t perform that action at this time.
0 commit comments