previewgenerator icon indicating copy to clipboard operation
previewgenerator copied to clipboard

Implement command to reset the pid lock

Open XA21X opened this issue 7 years ago • 4 comments

Since #93, I don't believe pid is ever reset as a fail-safe?

Logs indicated that pre-generate was always returning command is already running so I was getting suspicious. I finally checked the appconfig and noticed that pid == 1, which will never not be running.

I believe this could happen if the preview generator crashes or is interrupted while executing php occ directly (via docker run/exec). If this is the case, some time-based check might still be valuable in addition to the pid check - that is, periodically update a watchdog timestamp in the appconfig and treat the previous instance as dead if it hasn't been updated for a while?

XA21X avatar Jun 11 '18 13:06 XA21X

Or it might be easier to just special-case PID1? :P

XA21X avatar Jun 11 '18 14:06 XA21X

I believe this could happen if the preview generator crashes or is interrupted while executing php occ directly (via docker run/exec).

Agreed, this could happen under some circumstances:

https://github.com/nextcloud/previewgenerator/blob/bf04c0afc850db10fc0a4f74234b17fc1c241462/lib/Command/PreGenerate.php#L105-L115

Or it might be easier to just special-case PID1? :P

True, it is probably most likely to happen with 1. Tempting! :)

Maybe also with Docker environments with their own PID namespaces?

If this is the case, some time-based check might still be valuable in addition to the pid check - that is, periodically update a watchdog timestamp in the appconfig and treat the previous instance as dead if it hasn't been updated for a while?

Maybe. Or just check for the other matching running processes (that look like other copies of us) outright and error out as already running in that case.

Related: #328

joshtrichards avatar Mar 30 '24 14:03 joshtrichards

That is weird. Running exec should not start the command with PID 1 inside the running container.

But yeah, having a command to reset the pid lock or a fail-safe is probably a good idea.

st3iny avatar Apr 22 '24 11:04 st3iny

In the meantime, the log can be reset by running the following raw SQL query:

DELETE FROM
  oc_appconfig
WHERE
  appid = 'previewgenerator'
  AND configkey = 'pid';

st3iny avatar May 12 '24 09:05 st3iny