Treat empty multiprocess .db files as empty metrics - #1206
Closed
sankalpsthakur wants to merge 1 commit into
Closed
Conversation
MmapedDict.__init__ creates the backing file and only truncates it to _INITIAL_MMAP_SIZE afterwards, so a reader can observe a 0-byte file. A worker killed in that window leaves the empty file behind permanently, and read_all_values_from_file then raises struct.error, aborting the whole MultiProcessCollector merge. Treat an empty read as a file with nothing recorded yet so collection continues for other workers. Non-empty corrupt files still fail loudly. Fixes prometheus#1199 Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Sankalp Thakur <sankalpsthakur@users.noreply.github.com>
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.
Fixes #1199.
MmapedDict.__init__creates the backing file before sizing it, so it exists at 0 bytes for a moment.read_all_values_from_filethen unpacks a header that is not there, raisingstruct.errorand aborting the wholeMultiProcessCollectormerge — including metrics from every other worker.A worker killed in that window leaves the empty file behind for good (it is named after a pid that never returns), so subsequent scrapes fail permanently.
This treats an empty read as a file with nothing recorded yet, the read-side mirror of
__init__'scapacity == 0branch. Non-empty files are unchanged: a file that claims more than it holds still raises, and_read_all_values's corruption check is untouched.@csmarchbanks