@@ -259,7 +259,7 @@ func (s *session) runRetriable(
259
259
DatabaseName : s .databaseName ,
260
260
}
261
261
for state .Continue () {
262
- if workResult := s .tryRun (& state , mode , & config , work ); workResult != nil {
262
+ if workResult , successfullyCompleted := s .tryRun (& state , mode , & config , work ); successfullyCompleted {
263
263
return workResult , nil
264
264
}
265
265
}
@@ -292,12 +292,12 @@ func (s *session) WriteTransaction(
292
292
return s .runRetriable (db .WriteMode , work , configurers ... )
293
293
}
294
294
295
- func (s * session ) tryRun (state * retry.State , mode db.AccessMode , config * TransactionConfig , work TransactionWork ) interface {} {
295
+ func (s * session ) tryRun (state * retry.State , mode db.AccessMode , config * TransactionConfig , work TransactionWork ) ( interface {}, bool ) {
296
296
// Establish new connection
297
297
conn , err := s .getConnection (mode )
298
298
if err != nil {
299
299
state .OnFailure (conn , err , false )
300
- return nil
300
+ return nil , false
301
301
}
302
302
defer s .pool .Return (conn )
303
303
txHandle , err := conn .TxBegin (db.TxConfig {
@@ -308,7 +308,7 @@ func (s *session) tryRun(state *retry.State, mode db.AccessMode, config *Transac
308
308
})
309
309
if err != nil {
310
310
state .OnFailure (conn , err , false )
311
- return nil
311
+ return nil , false
312
312
}
313
313
314
314
tx := retryableTransaction {conn : conn , fetchSize : s .fetchSize , txHandle : txHandle }
@@ -321,17 +321,17 @@ func (s *session) tryRun(state *retry.State, mode db.AccessMode, config *Transac
321
321
// but instead rely on pool invoking reset on the connection, that
322
322
// will do an implicit rollback.
323
323
state .OnFailure (conn , err , false )
324
- return nil
324
+ return nil , false
325
325
}
326
326
327
327
err = conn .TxCommit (txHandle )
328
328
if err != nil {
329
329
state .OnFailure (conn , err , true )
330
- return nil
330
+ return nil , false
331
331
}
332
332
333
333
s .retrieveBookmarks (conn )
334
- return x
334
+ return x , true
335
335
}
336
336
337
337
func (s * session ) getServers (ctx context.Context , mode db.AccessMode ) ([]string , error ) {
0 commit comments