← Back to Pull requests

feat(share-consumer): renew the acquisition lock of a message #561

Closed
unknown closed this pull request without merging on Dec 02, 2026 18:02 UTC
View on GitHub
unknown unknown commented on Dec 02, 2026 08:27 UTC
Author

Next part of #480, following #560 (explicit acknowledgements): message.acknowledge('renew'), which extends the acquisition lock of a record that takes long to process.

What it does

  • In the explicit acknowledgement mode, acknowledge('renew') renews the lock of the record. The record stays with the member and still needs accept, release or reject afterwards. It can be renewed more than once.

  • A renew cannot be sent with a fetch: the broker accepts a ShareFetch with isRenewAck only when it fetches nothing. So it goes on its own, with ShareAcknowledge and isRenewAck, right away when the session is idle, or right after the request in flight on that broker. Other pending acknowledgements of the session go with it.

  • An accept, release or reject queued before the renew is sent replaces it, and a second renew of the same record is not queued twice. Closing the stream releases a renewed record like any other unacknowledged one.

  • It needs version 2 of ShareAcknowledge (Apache Kafka 4.2), which sends the renews. On older brokers, or with ShareAcknowledge pinned below version 2, acknowledge('renew') throws.

  • Since #560 the stream forgets a message once its lock expires. The lock the stream counts restarts only when the broker confirms the renew, from the time the renew was sent, since the broker restarts it when it gets the renew. The record then moves to the end of the unacknowledged records, so they stay in the order their locks expire.

  • When the renew fails, or was sent after the lock expired, the stream forgets the message like an expired one. Otherwise a renew waiting for the fetch in flight could outlive the lock, and a later accept would acknowledge a new delivery of the record.
  • Checked on the broker

    On cp-kafka:8.2.0, by hand:

  • a RENEW sent 9 s into a 15 s lock kept the record locked: at 17 s another member got the records whose lock expired, but not the renewed one, and the ACCEPT after the renew worked

  • RENEW with isRenewAck: false fails with INVALID_REQUEST, and isRenewAck: true accepts other types in the same request

  • a ShareFetch with isRenewAck: true needs maxWaitMs, minBytes, maxBytes and maxRecords at 0, and acquires nothing

  • while a ShareFetch waits on the broker, a ShareAcknowledge on the same connection is answered only after it, and one sent on another connection is accepted but makes the waiting fetch fail with INVALID_SHARE_SESSION_EPOCH. So a renew waits for the request in flight, at most maxWaitTime.
  • Tests

  • New mocked tests: a renew sent right away on an idle session, and after the fetch in flight otherwise, never with a fetch; the record still needing its acknowledgement and being released on close; an acknowledgement replacing a pending renew and a repeated renew; brokers without version 2 of ShareAcknowledge; a renewed record still acknowledged after its first lock expired, once the broker confirmed the renew, while the other record of the same fetch is not; a renew waiting for the fetch in flight until the lock expired, which fails without the fix; a renew the broker refuses.

  • One new broker test: a record renewed 10 s into a 15 s lock is not delivered to another member at 17 s. It passes locally, and it fails without the renew.

  • Not run locally: the rest of the suite, which needs the 3-broker cluster, and the other Kafka versions.
  • Diff: 422 lines (+316 / -106) across 5 files Reviewer: ShogunPanda Review duration: 574m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 422 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.362
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #561"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45% (MEDIUM) · Higher = larger blast radius
    45%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.8% · Safe to merge
    17.8%