batch: handle serialization errors correctly
This commit is contained in:
2 files changed
+89
-2
No files matched your search
+15
-2
@@ -5,6 +5,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/lightningnetwork/lnd/sqldb"
|
||||
)
|
||||
|
||||
// errSolo is a sentinel error indicating that the requester should re-run the
|
||||
@@ -55,8 +56,20 @@ func (b *batch) run() {
|
||||
for i, req := range b.reqs {
|
||||
err := req.Update(tx)
|
||||
if err != nil {
|
||||
failIdx = i
|
||||
return err
|
||||
// If we get a serialization error, we
|
||||
// want the underlying SQL retry
|
||||
// mechanism to retry the entire batch.
|
||||
// Otherwise, we can succeed in an
|
||||
// sqldb retry and still re-execute the
|
||||
// failing request individually.
|
||||
dbErr := sqldb.MapSQLError(err)
|
||||
if !sqldb.IsSerializationError(dbErr) {
|
||||
failIdx = i
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return dbErr
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in new issue
Block a user