Repository navigation
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR updates MqttIO checkpoint handling to mirror the recent JmsIO improvements (#40605, #41013), ensuring that restored checkpoints and unfinalized earlier checkpoints are properly acknowledged via a per-JVM PendingCheckpoints registry, and delaying client disconnection on close() until in-flight checkpoints finalize or time out.
🔍 General Feedback
- The design and implementation cleanly align with
JmsCheckpointMark, preserving backward serialization compatibility via the pinnedserialVersionUIDand preventing memory leaks through weak-valued cache entries. - One edge case was identified in
UnboundedMqttReader.start()where an emptyclientIdoverwrites the client ID passed intoPrepareron resume.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
| checkpointMark == null | ||
| ? new MqttCheckpointMark.Preparer() | ||
| : new MqttCheckpointMark.Preparer(checkpointMark); | ||
| : new MqttCheckpointMark.Preparer(checkpointMark.clientId); |
There was a problem hiding this comment.
🟡 Medium: createReader initializes Preparer with checkpointMark.clientId, and ConnectionConfiguration.createClient() always generates a new random UUID client ID when connecting. However, if UnboundedMqttReader is used in a test or with a client whose config has no identifier (client.getConfig().getClientIdentifier() is empty), start() sets this.clientId = "" and overwrites checkpointPreparer.clientId with "" (line 842). Furthermore, ConnectionConfiguration.createClient() never reuses checkpointMark.clientId when reconnecting a resumed reader, which may prevent the MQTT broker from resuming the previous client's session.
|
Assigning reviewers: R: @ahmedabu98 for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
|
Reminder, please take a look at this pr: @ahmedabu98 |
Similar to the recent JmsIO fixes (#40605, #41013),
MqttCheckpointMarkpreviously stored pendingMqtt3Publishmessages only in atransientlist:MqttCheckpointMark(or recreates the reader),readObjectresetsmessagesto an empty list, sofinalizeCheckpoint()silently acknowledges nothing and messages are redelivered.createReader(..., checkpointMark)resume, andUnboundedMqttReader.close()immediately disconnects the MQTT client before in-flight checkpoints finalize.Changes
PendingCheckpointsregistry (readerId+ monotonicsequenceonMqttCheckpointMark, withserialVersionUIDpinned for backward compatibility).finalizeCheckpoint()resolves the live reader'sPendingCheckpoints(even from a restored copy) and acknowledges this checkpoint together with all earlier unfinalized checkpoints of the same reader in order.UnboundedMqttSource.createReader(options, checkpointMark)finalizes the checkpoint it resumes from when its originating reader is still live in the same JVM.UnboundedMqttReader.close()waits for in-flight checkpoints to finalize (up to a 60s timeout, closing immediately once drained) before disconnecting the MQTT client, abandoning any remaining pending checkpoints on timeout.MqttIOTestcovering restored checkpoint finalization, catching up earlier checkpoints, empty checkpoints, and resuming viacreateReader.