diff --git a/glusterd2/transaction/transaction.go b/glusterd2/transaction/transaction.go index 3feab740..3cb5c3ba 100644 --- a/glusterd2/transaction/transaction.go +++ b/glusterd2/transaction/transaction.go @@ -13,6 +13,8 @@ import ( "github.com/coreos/etcd/clientv3/concurrency" "github.com/pborman/uuid" log "github.com/sirupsen/logrus" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" ) const ( @@ -133,6 +135,9 @@ func (t *Txn) Do() error { } if err := s.do(t.OrigCtx, t.Ctx); err != nil { + if t.DontCheckAlive && isNodeUnreachable(err) { + continue + } expTxn.Add("initiated_txn_failure", 1) if !t.DisableRollback { t.Ctx.Logger().WithError(err).Error("Transaction failed, rolling back changes") @@ -146,6 +151,18 @@ func (t *Txn) Do() error { return nil } +func isNodeUnreachable(err error) bool { + unreachable := true + if s, ok := err.(*stepResp); ok { + for _, e := range s.Resps { + if grpc.Code(e.Error) != codes.Unavailable { + unreachable = false + } + } + } + return unreachable +} + // undo undoes a transaction and will be automatically called by Perform if any step fails. // The Steps are undone in the reverse order, from the failed step. func (t *Txn) undo(n int) {