feat(share-consumer): consume records with implicit acknowledgement (KIP-932) #545
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #545"
general
weight: 0.35
ShogunPanda
Next part of #480, on top of #536:
ShareConsumer.consume()fetches records from a share group and acknowledges them implicitly. Explicit acknowledgements (accept,release,reject,renew) come in the next PR.What it does
consume({ topics })joins the group if needed and returns aShareMessagesStream. If the consumer has already joined, the topics must be the same. Only one stream can be open at a time, since the broker keeps one share session per member on each broker.forgotten_topics_data.deliveryCount. Offsets of an acquired range without a record (transaction markers, compacted records) are acknowledged as GAP.for await, adatalistener, a pipe orread(). The acknowledgement goes with the next ShareFetch to the same broker. While the buffer is full no ShareFetch is sent, so the pending acknowledgements go with a ShareAcknowledge on each heartbeat, before the acquisition locks expire.stream.close()releases the records still in the buffer and closes each session with ShareAcknowledge epoch -1, sending the pending acknowledgements. It waits for the request inflight on the session first, so the acknowledgements of a request which fails are sent with the closing one. Afor awaitloop ends cleanly, and the buffered records never reach it.leaveGroup()fails while a stream is consuming, likeConsumer.leaveGroup(). Withforceit closes the stream first, since the broker refuses the acknowledgements of a member that left.close()works the same way, likeConsumer.close(). A stream that afor awaitloop left withbreakdoes not needforce.retriesandretryDelay, or destroy the stream; a partition error which cannot be retried wins over one which can. Partition errors also refresh the metadata.UserErrorofBasenow carries the protocol error ascauseand thetopicname; the message is unchanged.share-consumer:acknowledgement:errorwith the topic and the partition.consume:deserializers,minBytes,maxBytes,maxWaitTime,maxRecords(500) andhighWaterMark(defaults tomaxRecords).ShareConsumertakes the same four type parameters asConsumer, with the same defaults.After the reviews
leaveGroup()andclose()needforceto close a consuming stream, as inConsumer.joinGroup()andconsume()say when the consumer is still joining.read()alone works,leaveGroup()waits for a forced leave in progress, and there is noanyleft.close()takesforce, likeConsumer.close(). Neitherclose()norleaveGroup()needs it for a stream that afor awaitloop left withbreak, which is still closing its sessions.Tests
close()fromfor await, from adatahandler and with areadablelistener, session errors (including a replaced session whose broker leads nothing anymore), acknowledgements sent with the heartbeats under backpressure, requests failing while the stream closes, idle sessions being closed, retries, partition and acknowledgement errors, assignment changes, several leaders, backpressure, waiting for the membership, ShareFetch and ShareAcknowledge v1 and v2, deserializers, a deleted topic of the assignment,leaveGroup()andclose()with and withoutforce, and both after breaking out of afor awaitloop. They cover 98.5% of the lines and 93.7% of the branches ofmessages-stream.ts, so the coverage gate holds where the broker test is skipped.cp-kafka:8.2.0, and skips itself like the #536 test where share groups are not available.cp-kafka:8.2.0:- acknowledgements in an epoch 0 request fail with INVALID_REQUEST
- a partition can be acknowledged and removed from the session in the same request
- closing a session releases its records
- an empty epoch 0 session can be opened, and its closing ShareAcknowledge accepts the records acquired by an older session
- a new epoch 0 session of the same member does not release the records of the old one, and can accept them
- a transaction marker inside an acquired range is accepted as GAP
- accepting a record after its lock expired fails with INVALID_RECORD_STATE
- with
highWaterMark: 1, a 15 s lock and one record read out of five, then 17 s of waiting: before this change the record was delivered again to the next member (delivery count 2), now it is accepted in time and is not- with three members, a stream that read 10 of 30 records and closed left exactly the other 20 for the next member, and nothing for a third