Skip to content

Commit

Permalink
broker/client: Appender retries on insufficient journal brokers
Browse files Browse the repository at this point in the history
This happens when a journal is new and the topology is converging.
It shouldn't result in a terminal Append failure.
  • Loading branch information
jgraettinger committed Dec 13, 2023
1 parent 6ab1e54 commit 0f225e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion broker/client/appender.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func Append(ctx context.Context, rjc pb.RoutedJournalClient, req pb.AppendReques
return a.Response, nil
} else if s, ok := status.FromError(err); ok && s.Code() == codes.Unavailable {
// Fallthrough to retry
} else if err == ErrNotJournalPrimaryBroker {
} else if err == ErrNotJournalPrimaryBroker || err == ErrInsufficientJournalBrokers {
// Fallthrough.
} else {
return a.Response, err
Expand Down
4 changes: 2 additions & 2 deletions broker/client/appender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (s *AppenderSuite) TestAppendCases(c *gc.C) {
{status: pb.Status_NOT_JOURNAL_PRIMARY_BROKER},
{status: pb.Status_OK},
// Case 2: Unexpected status is surfaced.
{status: pb.Status_INSUFFICIENT_JOURNAL_BROKERS},
{status: pb.Status_WRONG_APPEND_OFFSET},
// Case 3: As are errors.
{err: errors.New("an error")},
}
Expand Down Expand Up @@ -273,7 +273,7 @@ func (s *AppenderSuite) TestAppendCases(c *gc.C) {

// Case 2: Unexpected status is surfaced.
_, err = Append(ctx, rjc, pb.AppendRequest{Journal: "a/journal"}, con, tent)
c.Check(err, gc.ErrorMatches, "INSUFFICIENT_JOURNAL_BROKERS")
c.Check(err, gc.ErrorMatches, "WRONG_APPEND_OFFSET")

// Case 3: As are errors.
_, err = Append(ctx, rjc, pb.AppendRequest{Journal: "a/journal"}, con, tent)
Expand Down

0 comments on commit 0f225e4

Please sign in to comment.