Deduplication fails when the batch message contains duplicate message and valid message
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
- #1565 di @Mohith26 — chiusa senza merge
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 58/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- go
- Ambito
- distributed-systems
Direzione di ricerca
Inizia eseguendo la riproduzione Go fornita con Pulsar 4.0.5, quindi traccia il batching del client Go e la gestione degli identificatori di sequenza per SendAsync. Il lavoro è completato quando una SequenceID duplicata svuota il batch corrente prima che venga aggiunto il nuovo messaggio, così che consumando il topic venga mantenuto il messaggio realmente nuovo e venga eliminato solo il duplicato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Expected behavior
When a producer resends a duplicate SequenceID while batching is enabled, the client should flush the current batch and start a new one.
This guarantees that a batch never contains both old/duplicate and new SequenceIds, allowing the broker‑side deduplication logic to drop only the duplicates and accept the genuinely new messages.
This is the behavior of the Java client since PR apache/pulsar#6326.
Actual behavior
With the Go client (v0.15.0) the duplicate and new messages are added to the same batch.
Because the outer CommandSend carries only the lowest SequenceId in the batch, the broker cannot determine that newer messages are present; it treats the entire batch as a duplicate and drops it — including the fresh messages.
Steps to reproduce
package main
import (
"context"
"fmt"
"log"
"sync"
"time"
"github.com/apache/pulsar-client-go/pulsar"
)
func main() {
// ---------- set up ----------
client, err := pulsar.NewClient(pulsar.ClientOptions{
URL: "pulsar://localhost:6650",
OperationTimeout: 5 * time.Second,
ConnectionTimeout: 5 * time.Second,
})
if err != nil {
log.Fatalf("client: %v", err)
}
defer client.Close()
const topic = "persistent://public/default/dedupe-go-batch-bug"
const producerName = "go-dedupe-test"
prod, err := client.CreateProducer(pulsar.ProducerOptions{
Topic: topic,
Name: producerName,
DisableBatching: false,
BatchingMaxPublishDelay: 1 * time.Second,
})
if err != nil {
log.Fatalf("producer: %v", err)
}
defer prod.Close()
// helper to send one async msg and wait for ack
send := func(seq int64, wg *sync.WaitGroup) {
wg.Add(1)
prod.SendAsync(context.Background(),
&pulsar.ProducerMessage{
Payload: []byte(fmt.Sprintf("seq-%d", seq)),
SequenceID: &seq,
},
func(id pulsar.MessageID, _ *pulsar.ProducerMessage, err error) {
log.Printf("Send cb seq=%d err=%v", seq, err)
wg.Done()
})
}
// ---------- 1) first batch: seq 0,1 ----------
var wg sync.WaitGroup
send(0, &wg)
send(1, &wg)
wg.Wait() // ensure broker acks first batch
time.Sleep(1 * time.Second) // let batch window expire
// ---------- 2) second batch with duplicate + new ----------
// we issue them back‑to‑back so they land in the SAME batch
send(0, &wg) // duplicate
send(2, &wg) // new
wg.Wait()
prod.Flush()
// ---------- consume to see what really persisted ----------
cons, _ := client.Subscribe(pulsar.ConsumerOptions{
Topic: topic,
SubscriptionName: "check",
Type: pulsar.Exclusive,
SubscriptionInitialPosition: pulsar.SubscriptionPositionEarliest,
})
defer cons.Close()
got := map[string]struct{}{}
for {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
msg, err := cons.Receive(ctx)
cancel()
if err != nil {
break
}
got[string(msg.Payload())] = struct{}{}
cons.Ack(msg)
}
fmt.Println("messages stored:")
for k := range got {
fmt.Println(" ", k)
}
}
System configuration
Pulsar version: 4.0.5
- Lingua principale
- Go
- Stelle
- 746
- Fork
- 394
- Merge medio
- 6g 13h
- PR unite (30g)
- 7
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/pulsar-client-go
-
[Bug] Default key routing (JavaStringHash) picks a different partition than the Java client for about half of keysForse già presa @0z5a l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
apache/pulsar-client-go#1575 ·
I maintainer di solito rispondono entro 2 giorni
-
[Bug] Concurrent transactional ACKs can crash in registerAckTopicForse già presa @Ebispongebob l’ha presa 73 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/pulsar-client-go#1536 ·
I maintainer di solito rispondono entro 2 giorni
-
Nil pointer panic in `sendRequest.done()` during producer reconnection via `FailTimeoutMessages`Forse già presa @nodece l’ha presa 186 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
apache/pulsar-client-go#1497 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
[Bug][Consumer] Throughput collapse and permanent deadlock on large payloads since v0.20.0Forse già presa @HrithikShet l’ha presa 2 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 32/100
apache/pulsar-client-go#1573 ·
I maintainer di solito rispondono entro 2 giorni
-
[Bug] Lookup retries use a fixed backoff that doubles to 60 s, so a reconnect during a broker outage can sleep through the failoverForse già presa @EdwardShen125 l’ha presa 26 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 54/100
apache/pulsar-client-go#1554 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di apache/pulsar-client-go
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
otelc go test fails for .go file targets with 'multiple packages found for file targets'Forse già presa @Aryanbhargava18 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
open-telemetry/opentelemetry-go-compile-instrumentation#1877 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
rossoctl/context-guru#1268 ·
I maintainer di solito rispondono entro 1 giorno