Skip to content

Influx: buffer writes while the database is unavailable, with tests - #413

Open
isarrider wants to merge 3 commits into
volkszaehler:masterfrom
isarrider:feat/influx-buffer
Open

isarrider wants to merge 3 commits into
volkszaehler:masterfrom
isarrider:feat/influx-buffer

Conversation

@isarrider

@isarrider isarrider commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

This is andig's implementation from #406, unchanged and rebased onto current master, plus tests and a clearer description of the default.

From #406 (andig)
--influx-buffer / influx.buffer keeps unsent readings in memory and retries them for that long while InfluxDB is unavailable, e.g. 1h.

Added

  • server/influx_test.go:
    • unit tests for the buffer options
    • an outage test against a fake InfluxDB that checks every reading arrives once the database is back
    • a test showing that without a buffer, data is lost during a longer outage
  • Flag help and example config now describe the default fully: 0 keeps the client default of 5 retries within 3 minutes, which holds about 10 seconds of data.

🤖 Generated with Claude Code

andig and others added 3 commits November 4, 2026 07:38
fixes volkszaehler#242

Adds --influx-buffer (config: influx.buffer), a duration for which
readings are kept in memory and retried when InfluxDB cannot be reached.
The client already batches writes and keeps a retry queue; with a buffer
set, retries become unbounded and the queue is sized to hold the batches
of that duration, dropping the oldest once full. Without the option the
client default of 5 retries within 3 minutes stays in effect.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- TestInfluxBufferOptions checks the retry queue size, retry count and
  retry time derived from the buffer duration, including the client
  defaults for 0 and the one-batch minimum
- TestInfluxOutage simulates a 20s database outage against a fake
  server and checks that every point is delivered with a 1h buffer
- TestInfluxOutageDefault checks that the same outage loses data with
  the client defaults, so the outage test is meaningful

The outage tests are skipped with -short.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XzyNHxELw6PasHKku3kreU
Without a buffer the client retries 5 times within 3 minutes but only
keeps 10 batches of points, about 10 seconds of data at one flush per
second. Say both in the flag help and the example config.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KmuA1dQ8QTTW8pao9KcJS2
isarrider pushed a commit to isarrider/mbmd that referenced this pull request Nov 16, 2026
The influx row now points at the open upstream PR volkszaehler#413 and notes that
andig rejected a parameter for this in volkszaehler#406. A new table lists every
upstream PR from this fork, what it was and where closed ones continued.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KmuA1dQ8QTTW8pao9KcJS2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants