From d97853b9debf3e1afdefc7e394680132a08c4563 Mon Sep 17 00:00:00 2001 From: yfsn666 Date: Wed, 19 Aug 2026 22:18:44 +0800 Subject: [PATCH] [INLONG-12197][SDK] Make batch done idempotent in Dataproxy Go SDK --- .../dataproxy-sdk-golang/dataproxy/request.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/dataproxy/request.go b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/dataproxy/request.go index 1eabd39e8a..03e060c0f4 100755 --- a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/dataproxy/request.go +++ b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/dataproxy/request.go @@ -87,6 +87,7 @@ func (h heartbeatReq) encode(buffer *bytes.Buffer) []byte { type batchCallback func() type batchReq struct { pool *sync.Pool + finished bool workerID string batchID string groupID string @@ -111,6 +112,13 @@ func (b *batchReq) append(req *sendDataReq) { } func (b *batchReq) done(err error) { + // Idempotency guard: if the batch has already been done, return immediately + // to avoid releasing resources or invoking callbacks more than once. + if b.finished { + return + } + b.finished = true + errorCode := getErrorCode(err) for i, req := range b.dataReqs { req.done(err, errorCode)