GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||
GeezerVison is showing github.com — aclk: MQTT keepalive starved by traffic and tied to the wall clock by stelfrag · Pull Request #24427 · netdata/netdata Conversation
|
| scenario | master | branch |
|---|---|---|
| PUBLISH every 0.5 s, PINGRESP withheld | still connected after 220 s | reconnects 60 s after PINGREQ |
| wall clock +3600 s, PINGRESP after 20 s | false ping timeout | stays connected |
| wall clock -3600 s, PINGRESP withheld | not detected (160 s+) | reconnects 60 s after PINGREQ |
| no traffic, PINGRESP withheld | reconnects ~61 s after | reconnects 60 s after |
| PUBACK withheld, clock -3600 s | packets never time out | timed out after ~110 s |
| PUBACK withheld, clock +3600 s | timed out at ~100 s | timed out at ~100 s |
-W aclktimeouttest and -W mqttngtest pass on every commit; new unit tests cover the keepalive state machine and the poll bound.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The PINGREQ was requested, and its PINGRESP deadline checked, only when poll() timed out, so a link with steady inbound traffic never noticed an unanswered ping. The deadline and the keepalive base also used the wall clock, so a clock step fired a false timeout or postponed a real one. Evaluate the keepalive on every call, bound poll() by its next due time, use the monotonic clock, and keep the ping state in the MQTT client instead of a global.
The deadlines were wall-clock seconds since 2024: a backward step, or a clock still before 2024 on a board without an RTC, kept them from ever expiring.
A ping queued behind a long message could expire while that message was still being written. Start the wait when the PINGREQ is handed to the WebSocket layer; while it is still queued, expire it only if writing stops making progress. Report a socket error seen at the deadline as such, not as a ping timeout.
There was an error while loading. Please reload this page.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
MQTT monotonic timing and ping lifecycle src/aclk/mqtt_websockets/mqtt_ng.h, src/aclk/mqtt_websockets/mqtt_ng.c |
PUBACK deadlines and send timestamps now use monotonic time. The client records ping request and submission times, exposes accessors and a reset function, and clears ping state on response or reconnect. |
Per-connection keepalive scheduling and expiry src/aclk/mqtt_websockets/mqtt_wss_client.c |
The client schedules keepalives at three-quarters of the interval and bounds poll() by the next deadline. It tracks transmit progress for queued pings and handles ping expiry with a ping reset and disconnect request. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
sequenceDiagram
participant mqtt_wss_service
participant mqtt_ng
participant SSL_write
participant ACLK
mqtt_wss_service->>mqtt_ng: Queue a PINGREQ when a keepalive is due
mqtt_wss_service->>SSL_write: Write queued MQTT data
SSL_write-->>mqtt_wss_service: Report transmit progress
mqtt_wss_service->>mqtt_ng: Read ping timestamps and reset an expired ping
mqtt_wss_service->>ACLK: Request a ping-timeout disconnect
Suggested reviewers: thiagoftsm
573fdNo identified keepalive or timeout issue remains to resolve before merging; normal checks still apply.
Explanation
The title clearly identifies the two main changes: preventing MQTT keepalive starvation under traffic and removing wall-clock dependence from timing. It is concise, specific, and matches the pull request objectives.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
All charts and communication with cloud are working as expected. LGTM!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…24427) * aclk: check the MQTT keepalive on every service call The PINGREQ was requested, and its PINGRESP deadline checked, only when poll() timed out, so a link with steady inbound traffic never noticed an unanswered ping. The deadline and the keepalive base also used the wall clock, so a clock step fired a false timeout or postponed a real one. Evaluate the keepalive on every call, bound poll() by its next due time, use the monotonic clock, and keep the ping state in the MQTT client instead of a global. * aclk: use the monotonic clock for MQTT PUBACK deadlines The deadlines were wall-clock seconds since 2024: a backward step, or a clock still before 2024 on a board without an RTC, kept them from ever expiring. * aclk: start the PINGRESP wait when the PINGREQ is submitted A ping queued behind a long message could expire while that message was still being written. Start the wait when the PINGREQ is handed to the WebSocket layer; while it is still queued, expire it only if writing stops making progress. Report a socket error seen at the deadline as such, not as a ping timeout. (cherry picked from commit a5f16c9)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.