txn: IllegalGeneration should not cause End to error
Starting 2.5.0, if the generation on the txn offset commit req is out of
date, we get IllegalGeneration. We abort the txn, but we also should not
return an error.
With this and the prior commit, tests pass on 2.5.0
@@ -137,6 +137,7 @@ func (s *GroupTransactSession) End(ctx context.Context, commit TransactionEndTry
precommit := s.cl.CommittedOffsets()
postcommit := s.cl.UncommittedOffsets()
+ var oldGeneration bool
var commitErr error
if wantCommit && !revoked {
var commitErrs []string
@@ -153,10 +154,14 @@ func (s *GroupTransactSession) End(ctx context.Context, commit TransactionEndTry
for _, t := range resp.Topics {
for _, p := range t.Partitions {
if err := kerr.ErrorForCode(p.ErrorCode); err != nil {
+ if err == kerr.IllegalGeneration {
+ oldGeneration = true
+ } else {
commitErrs = append(commitErrs, fmt.Sprintf("topic %s partition %d: %v", t.Topic, p.Partition, err))
}
}
}
+ }
},
)
<-committed
@@ -169,7 +174,7 @@ func (s *GroupTransactSession) End(ctx context.Context, commit TransactionEndTry
s.revokeMu.Lock()
defer s.revokeMu.Unlock()
- tryCommit := !s.revoked && commitErr == nil
+ tryCommit := !s.revoked && commitErr == nil && !oldGeneration
willTryCommit := wantCommit && tryCommit
s.cl.cfg.logger.Log(LogLevelInfo, "transaction session ending",
