Repository navigation
CA-432861: Re-map a plugin's shared file when it grows - #7370
Merged
Merged
Conversation
The v2 protocol has rrdd re-read all of a plugin's data when its metadata checksum changes, but the file reader maps the file once, at the length it had on first read. A plugin that adds datasources extends the file in place, as the Python rrdd library does, so the re-read runs off the end of the old mapping and fails on every tick: the plugin's datasources go dark until it re-registers. A plugin whose datasource set follows the VMs on a host hits this on the first VM start. Signed-off-by: Mark Syms <mark.syms@citrix.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarkSymsCtx
requested review from
LunfanZhang,
contificate,
cplaursen and
minglumlu
October 30, 2026 15:59
psafont
approved these changes
Oct 30, 2026
| let size = | ||
| try (Unix.stat state.path).Unix.st_size with Unix.Unix_error _ -> 0 | ||
| in | ||
| if size > Cstruct.length state.mapping then state.mapping <- map state.path ; |
Member
There was a problem hiding this comment.
This shouldn't leak memory, the memory reserved by map is held by a bigarray which installs a finalizer. Although this isn't made explicit in the documentation, it's present in the implementation:
https://github.com/ocaml/ocaml/blob/trunk/otherlibs/unix/mmap_ba.c#L74
https://github.com/ocaml/ocaml/blob/trunk/otherlibs/unix/mmap_ba.c#L28-L56
Contributor
Author
There was a problem hiding this comment.
Thanks for that @psafont , I'm reading that as the change being OK wrt. memory.
Member
There was a problem hiding this comment.
I'm reading that as the change being OK wrt. memory.
That's exactly it.
We've had problems in rrrds with memory leaks, and bigarrays are not generally garbage-collected, so I had to check it.
last-genius
requested changes
Nov 2, 2026
Re-mapping a grown file makes File.expose stat the file, so the two calls per read that were free before now cost two syscalls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Mark Syms <mark.syms@citrix.com>
last-genius
approved these changes
Nov 2, 2026
cplaursen
approved these changes
Nov 2, 2026
psafont
approved these changes
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The v2 protocol has rrdd re-read all of a plugin's data when its metadata checksum changes, but the file reader maps the file once, at the length it had on first read. A plugin that adds datasources extends the file in place, as the Python rrdd library does, so the re-read runs off the end of the old mapping and fails on every tick: the plugin's datasources go dark until it re-registers. A plugin whose datasource set follows the VMs on a host hits this on the first VM start.