Skip to content

Commit

Permalink
epn: improve detecting epn issues
Browse files Browse the repository at this point in the history
make epn worker die on invalid requests and detect those errors as well.
  • Loading branch information
sni committed Feb 8, 2024
1 parent 2bbe7df commit 23c235d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions epn.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ var (
ePNRestartPattern = []string{
"Attempt to free nonexistent shared string",
", Perl interpreter: ",
"**ePN: invalid request:",
"/mod_gearman_worker_epn.pl line ",
}
)

Expand Down Expand Up @@ -318,6 +320,16 @@ func executeWithEmbeddedPerl(cmd *command, result *answer, received *receivedStr
return fmt.Errorf("json unpacking failed: %w: %s", err, err.Error())
}

for _, p := range ePNRestartPattern {
if strings.Contains(res.Stdout, p) {
logger.Errorf("found epn error, triggering epn server restart")
logger.Errorf("%s", res.Stdout)
ePNStarted = nil
received.Canceled = true
return fmt.Errorf("check result matched restart pattern: %s", p)
}
}

result.output = res.Stdout
result.returnCode = res.RC
result.compileDuration = res.CompileDuration
Expand Down
2 changes: 2 additions & 0 deletions mod_gearman_worker_epn.pl
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ sub _handle_connection {
eval {
my $req = <$client>;
my $request = _parse_request($req);
die("**ePN: invalid request: ".($req // 'undef')) unless $request->{'bin'};
$res = _handle_request($request);
};
my $err = $@;
Expand Down Expand Up @@ -324,6 +325,7 @@ sub _test_run {
eval {
my $req = join(" ", @{$args});
my $request = _parse_request($req);
die("**ePN: invalid request: ".($req // 'undef')) unless $request->{'bin'};
$res = _handle_request($request, 1);
};
my $err = $@;
Expand Down

0 comments on commit 23c235d

Please sign in to comment.