Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[azservicebus] Handle 500 as a retryable code (no recovery needed) #16925

Merged
merged 5 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sdk/messaging/azservicebus/internal/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,13 @@ func GetRecoveryKind(err error) recoveryKind {
}

// simple timeouts
richardpark-msft marked this conversation as resolved.
Show resolved Hide resolved
if me.Resp.Code == 408 || me.Resp.Code == 503 {
if me.Resp.Code == 408 || me.Resp.Code == 503 ||
// internal server errors are worth retrying (they will typically lead
// to a more actionable error). A simple example of this is when you're
// in the middle of an operation and the link is detached. Sometimes you'll get
// the detached event immediately, but sometimes you'll get an intermediate 500
// indicating your original operation was cancelled.
me.Resp.Code == 500 {
return RecoveryKindNone
}
}
Expand Down
4 changes: 1 addition & 3 deletions sdk/messaging/azservicebus/internal/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func Test_ServiceBusError_NoRecoveryNeeded(t *testing.T) {
// simple timeouts from the mgmt link
mgmtError{Resp: &RPCResponse{Code: 408}},
mgmtError{Resp: &RPCResponse{Code: 503}},
mgmtError{Resp: &RPCResponse{Code: 500}},
}

for i, err := range tempErrors {
Expand Down Expand Up @@ -237,7 +238,4 @@ func Test_ServiceBusError_Fatal(t *testing.T) {
// unknown errors are also considered fatal
rk := GetSBErrInfo(errors.New("Some unknown error")).RecoveryKind
require.EqualValues(t, RecoveryKindFatal, rk, "some unknown error")

rk = GetSBErrInfo(mgmtError{Resp: &RPCResponse{Code: 500}}).RecoveryKind
require.EqualValues(t, RecoveryKindFatal, rk, "some unknown error")
}
8 changes: 8 additions & 0 deletions sdk/messaging/azservicebus/session_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ package azservicebus
import (
"context"
"errors"
"fmt"
"testing"
"time"

azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus/admin"
"github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus/internal"
Expand Down Expand Up @@ -268,6 +270,12 @@ func TestSessionReceiver_Detach(t *testing.T) {
})
defer cleanup()

azlog.SetListener(func(e azlog.Event, s string) {
fmt.Printf("%s %s\n", e, s)
})

defer azlog.SetListener(nil)

adminClient, err := admin.NewClientFromConnectionString(test.GetConnectionString(t), nil)
require.NoError(t, err)

Expand Down