Skip to content

MINOR: runtime: add atomic map replacement - #141

Open
tkjaer wants to merge 2 commits into
haproxytech:masterfrom
tkjaer:tkjaer/atomic-map-replacement
Open

tkjaer wants to merge 2 commits into
haproxytech:masterfrom
tkjaer:tkjaer/atomic-map-replacement

Conversation

@tkjaer

@tkjaer tkjaer commented Oct 30, 2026

Copy link
Copy Markdown

Summary

Adds ReplaceMapPayload to atomically replace all entries in a runtime map. Also fixes payload chunking that could drop or repeat entries across buffer boundaries.

Details

  • Requires HAProxy 2.4 or newer and returns an error on older versions.
  • Prepares and clears a new map version, adds entries in order, and commits only after every step succeeds.
  • Accepts an empty entry list, which empties the map.
  • Keeps the existing AddMapPayloadVersioned behavior, while ensuring its large-payload atomic path preserves every entry.

parseMapPayload could lose an entry when it crossed a chunk boundary,
lose deferred data after repeated crossings, or repeat stale data when
a chunk exactly matched the buffer size.

Build chunks with one buffer and flush it before adding an entry that
would exceed the limit. This preserves every entry in its original
order while keeping the existing AddMapPayloadVersioned size behavior.
Add ReplaceMapPayload to prepare a new map version, clear it, add the
desired entries in order, and commit only after every step succeeds.

Require HAProxy 2.4 or newer instead of falling back to a non-atomic
update. An empty entry list commits an empty map.
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.

1 participant