From 0cf70a33b3f05be237889c0a85e08ffb83dc821a Mon Sep 17 00:00:00 2001 From: Richard Park Date: Tue, 16 Jan 2024 15:47:18 -0800 Subject: [PATCH 1/2] Fixing memory leak with go-amqp update. --- sdk/messaging/azservicebus/CHANGELOG.md | 5 ++++ sdk/messaging/azservicebus/go.mod | 2 +- sdk/messaging/azservicebus/go.sum | 4 +-- sdk/messaging/azservicebus/receiver_test.go | 32 +++++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/sdk/messaging/azservicebus/CHANGELOG.md b/sdk/messaging/azservicebus/CHANGELOG.md index 13aba620af71..c18797d848e5 100644 --- a/sdk/messaging/azservicebus/CHANGELOG.md +++ b/sdk/messaging/azservicebus/CHANGELOG.md @@ -6,6 +6,11 @@ - ReceiverOptions.TimeAfterFirstMessage lets you configure the amount of time, after the first message in a batch is received, before we return messages. (PR#22154) +### Bugs Fixed + +- Settling a message (using CompleteMessage, AbandonMessage, etc..) on a different Receiver instance than you received on no + longer leaks memory. (PR#TBD) + ## 1.5.0 (2023-10-10) ### Features Added diff --git a/sdk/messaging/azservicebus/go.mod b/sdk/messaging/azservicebus/go.mod index c3207f28d6e2..f84531ed2265 100644 --- a/sdk/messaging/azservicebus/go.mod +++ b/sdk/messaging/azservicebus/go.mod @@ -8,7 +8,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.4.0 - github.com/Azure/go-amqp v1.0.2 + github.com/Azure/go-amqp v1.0.4 ) require ( diff --git a/sdk/messaging/azservicebus/go.sum b/sdk/messaging/azservicebus/go.sum index e8dbc91c53fe..16eda4152e31 100644 --- a/sdk/messaging/azservicebus/go.sum +++ b/sdk/messaging/azservicebus/go.sum @@ -6,8 +6,8 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdE github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= github.com/Azure/azure-sdk-for-go/sdk/internal v1.4.0 h1:TuEMD+E+1aTjjLICGQOW6vLe8UWES7kopac9mUXL56Y= github.com/Azure/azure-sdk-for-go/sdk/internal v1.4.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= -github.com/Azure/go-amqp v1.0.2 h1:zHCHId+kKC7fO8IkwyZJnWMvtRXhYC0VJtD0GYkHc6M= -github.com/Azure/go-amqp v1.0.2/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE= +github.com/Azure/go-amqp v1.0.4 h1:GX5OFOs706UjuFRD5PDKm3aOuLQ92F7DMbua+DKAYCc= +github.com/Azure/go-amqp v1.0.4/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE= github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/sdk/messaging/azservicebus/receiver_test.go b/sdk/messaging/azservicebus/receiver_test.go index bbeecb0b710e..6925955eb112 100644 --- a/sdk/messaging/azservicebus/receiver_test.go +++ b/sdk/messaging/azservicebus/receiver_test.go @@ -22,6 +22,38 @@ import ( "github.com/stretchr/testify/require" ) +func TestReceiverBackupSettlement(t *testing.T) { + serviceBusClient, cleanup, queueName := setupLiveTest(t, &liveTestOptions{ + QueueProperties: &admin.QueueProperties{ + LockDuration: to.Ptr("PT5M"), + }, + }) + defer cleanup() + + sender, err := serviceBusClient.NewSender(queueName, nil) + require.NoError(t, err) + + err = sender.SendMessage(context.Background(), &Message{ + Body: []byte("hello world"), + }, nil) + require.NoError(t, err) + + origReceiver, err := serviceBusClient.NewReceiverForQueue(queueName, nil) + require.NoError(t, err) + defer test.RequireClose(t, origReceiver) + + otherReceiver, err := serviceBusClient.NewReceiverForQueue(queueName, nil) + require.NoError(t, err) + defer test.RequireClose(t, otherReceiver) + + messages, err := origReceiver.ReceiveMessages(context.TODO(), 1, nil) + require.NoError(t, err) + require.NotEmpty(t, messages) + + err = otherReceiver.CompleteMessage(context.Background(), messages[0], nil) + require.NoError(t, err) +} + func TestReceiverCancel(t *testing.T) { serviceBusClient, cleanup, queueName := setupLiveTest(t, nil) defer cleanup() From 52e4d1e4a7e468b4a410b3a79fc2553d5ae5dac8 Mon Sep 17 00:00:00 2001 From: Richard Park Date: Tue, 16 Jan 2024 15:56:53 -0800 Subject: [PATCH 2/2] Update PR --- sdk/messaging/azservicebus/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/messaging/azservicebus/CHANGELOG.md b/sdk/messaging/azservicebus/CHANGELOG.md index c18797d848e5..011652c62bc2 100644 --- a/sdk/messaging/azservicebus/CHANGELOG.md +++ b/sdk/messaging/azservicebus/CHANGELOG.md @@ -9,7 +9,7 @@ ### Bugs Fixed - Settling a message (using CompleteMessage, AbandonMessage, etc..) on a different Receiver instance than you received on no - longer leaks memory. (PR#TBD) + longer leaks memory. (PR#22253) ## 1.5.0 (2023-10-10)