[Bug 24749] New: Plack restart should clear orphaned cgi_compile directories on restart
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24749 Bug ID: 24749 Summary: Plack restart should clear orphaned cgi_compile directories on restart Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: nick@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org When a plack process crashes you can end up with directories left from CGI::Compile in tmp These dirs are owned by the instance and named cgi_compile_{pid} Later on, other instances can generate the same dir name because the pid is reused. If these orphaned dirs still exist then plack locks up, unable to create/access the directory This may be a CGI::Compile bug, but if we can find a way to delete these on restart that would mitigate the issue -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24749 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org, | |kyle@bywatersolutions.com, | |m.de.rooy@rijksmuseum.nl, | |martin.renvoize@ptfs-europe | |.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24749 --- Comment #1 from Nick Clemens <nick@bywatersolutions.com> --- Related error code: Error in tempfile() using template /tmp/cgi_compile_2076/cgi_compile_XXXXX.pm: Could not create temp file /tmp/cgi_compile_2076/cgi_compile_gNjo5.pm: Permission denied at /usr/share/perl5/CGI/Compile.pm line 181. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24749 --- Comment #2 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 109826 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=109826&action=edit Bug 24749: Attempt to use tmp_path from koha-conf for TMPDIR for starman The issue described on this bug is triggered when a process ID is reused, but the directory belongs to another koha instance on the same server To mitigate this issue we attemtped to force plack to use an instance specific TMPDIR as CGI::Compile simply uses File::Spec::tmpdir to decide where to compile files If the folder belongs to the instance then we shouldn't have permissions issues Sadly these patches, while brilliant, do not work Attaching in the hopes someone even more brilliant can complete the work -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24749 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au, | |tomascohen@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24749 --- Comment #3 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Time for containers, Nick ? -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24749 --- Comment #4 from David Cook <dcook@prosentient.com.au> --- That's an interesting one. I would say that's a CGI::Compile bug/issue. Looking at https://metacpan.org/release/CGI-Compile/source/lib/CGI/Compile.pm, it's sad that they use File::Temp for the temporary file but not for the temporary directory. Bizarre. It looks like you're setting TMPDIR in the Plack middleware, but that's probably only going to be relevant to the PSGI application rather than the Plack code around it. I'd suggest setting TMPDIR in /etc/koha/plack.psgi. You should be able to call C4::Context->temporary_directory there. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24749 --- Comment #5 from David Cook <dcook@prosentient.com.au> --- Comment on attachment 109826 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=109826 Bug 24749: Attempt to use tmp_path from koha-conf for TMPDIR for starman Review of attachment 109826: --> (https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=24749&attachment=109826) ----------------------------------------------------------------- ::: Koha/Middleware/SetEnv.pm @@ +96,5 @@
} @setenv_headers;
+ $setenvs{TMPDIR} = C4::Context->temporary_directory; + # See bug 24749 +
I don't think CGI::Compile will see this, as this'll be set in the PSGI application I think. ::: debian/scripts/koha-plack @@ +84,5 @@
[ -z $PLACK_MAX_REQUESTS ] && PLACK_MAX_REQUESTS="50" PLACK_WORKERS=$(run_safe_xmlstarlet $instancename plack_workers) [ -z $PLACK_WORKERS ] && PLACK_WORKERS="2" + KOHATMPDIR=$(run_safe_xmlstarlet $instancename tmp_path) + [ -z $KOHATMPDIR ] || TMPDIR=$KOHATMPDIR
You need to export TMPDIR here. Otherwise, it's just going to be localized to this script. (But really you could just define it in plack.psgi instead, which would be a more robust solution for different deployments.) You can see this by how KOHA_CONF and PERL5LIB are exported in koha-plack. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24749 Jason Boyer <JBoyer@equinoxOLI.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |JBoyer@equinoxOLI.org -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org