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

fix: normalize all send request resource release into sr.done #1121

Merged
merged 13 commits into from
Oct 25, 2023
15 changes: 7 additions & 8 deletions pulsar/message_chunking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"math/rand"
"net/http"
"strings"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -531,12 +532,13 @@ func TestChunkBlockIfQueueFull(t *testing.T) {
assert.NotNil(t, producer)
defer producer.Close()

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
// Large messages will be split into 11 chunks, exceeding the length of pending queue
ID, err := producer.Send(context.Background(), &ProducerMessage{
_, err = producer.Send(ctx, &ProducerMessage{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for Fix 2.

Payload: createTestMessagePayload(100),
})
assert.NoError(t, err)
assert.NotNil(t, ID)
assert.Error(t, err)
}

func createTestMessagePayload(size int) []byte {
Expand Down Expand Up @@ -566,18 +568,15 @@ func sendSingleChunk(p Producer, uuid string, chunkID int, totalChunks int) {
&sendRequest{
callback: func(id MessageID, producerMessage *ProducerMessage, err error) {
},
callbackOnce: &sync.Once{},
ctx: context.Background(),
msg: msg,
producer: producerImpl,
flushImmediately: true,
totalChunks: totalChunks,
chunkID: chunkID,
uuid: uuid,
chunkRecorder: newChunkRecorder(),
transaction: nil,
reservedMem: 0,
sendAsBatch: false,
schema: nil,
schemaVersion: nil,
uncompressedPayload: wholePayload,
uncompressedSize: int64(len(wholePayload)),
compressedPayload: wholePayload,
Expand Down
Loading