Skip to content

Implement async grep result bounding and error handling - #778

Merged
tmaeno merged 3 commits into
PanDAWMS:masterfrom
tmaeno:master
Aug 31, 2026
Merged

Implement async grep result bounding and error handling#778
tmaeno merged 3 commits into
PanDAWMS:masterfrom
tmaeno:master

Conversation

@tmaeno

@tmaeno tmaeno commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

No description provided.

tmaeno added 3 commits August 30, 2026 17:50
_MAX_RESULT_BYTES caps the result stored in the database, not the output the
daemon buffers to produce it: capture_output=True reads the matcher's entire
stdout into this process before the slice is taken.  Log files here reach
6.0 GB (panda-DBProxy.log) and 2.3 GB (panda-JediDBProxy.log), so a pattern
that matches most lines -- a timestamp, a level, a common tag -- makes the
async_request_processor allocate that much and then throw nearly all of it
away.

The cap costs nothing to add, because everything past the byte limit was
already being discarded: no caller can receive more than 1 MB today, so
bounding the match count cannot lose a byte anyone could have seen.  It
applies by default, with the default set high enough that stored results and
their truncated flag are unchanged.

max_matches passes -m to the matcher, which both grep and rg spell the same
way, so it works compressed or not; it stops the scan as well as the output.
tail_bytes searches only the end of the file, which is how to ask about recent
activity in a log this size.  It is ignored for .gz, where an arbitrary offset
is not a valid stream.

The pipeline is built process to process, never through a shell -- the pattern
comes from the caller.  The read end is handed to the matcher and closed here,
so that a matcher exiting at its cap lets tail stop rather than leaving it
blocked on a pipe nobody drains.

truncated is now also set when the cap is reached.  A caller that reads a
capped result as "this never appears in the log" gets the wrong answer, and
that is the one mistake this data is used to avoid.

A missing log file is reported as failed with "No such file or directory"
rather than left to the tool.  With a tail window the matcher reads standard
input and never sees the path, so it would report no match for a file that is
not there -- and "the file does not exist" is a meaningful answer (nothing has
ever written it) that must not depend on how the query was built.  This turns
what was previously done/return_code=2 into failed, consistent with how the
handler already reports a timeout.
_MAX_RESULT_BYTES caps the result stored in the database, not the output the
daemon buffers to produce it: capture_output=True reads the matcher's entire
stdout into this process before the slice is taken.  Log files here reach
6.0 GB (panda-DBProxy.log) and 2.3 GB (panda-JediDBProxy.log), so a pattern
that matches most lines -- a timestamp, a level, a common tag -- makes the
async_request_processor allocate that much and then throw nearly all of it
away.

The cap costs nothing to add, because everything past the byte limit was
already being discarded: no caller can receive more than 1 MB today, so
bounding the match count cannot lose a byte anyone could have seen.  It
applies by default, with the default set high enough that stored results and
their truncated flag are unchanged.

max_matches passes -m to the matcher, which both grep and rg spell the same
way, so it works compressed or not; it stops the scan as well as the output.
tail_bytes searches only the end of the file, which is how to ask about recent
activity in a log this size.  It is ignored for .gz, where an arbitrary offset
is not a valid stream.

The pipeline is built process to process, never through a shell -- the pattern
comes from the caller.  The read end is handed to the matcher and closed here,
so that a matcher exiting at its cap lets tail stop rather than leaving it
blocked on a pipe nobody drains.

truncated is now also set when the cap is reached.  A caller that reads a
capped result as "this never appears in the log" gets the wrong answer, and
that is the one mistake this data is used to avoid.

A missing log file is reported as failed with "No such file or directory"
rather than left to the tool.  With a tail window the matcher reads standard
input and never sees the path, so it would report no match for a file that is
not there -- and "the file does not exist" is a meaningful answer (nothing has
ever written it) that must not depend on how the query was built.  This turns
what was previously done/return_code=2 into failed, consistent with how the
handler already reports a timeout.
@tmaeno
tmaeno merged commit 485046a into PanDAWMS:master Aug 31, 2026
1 check passed
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