From: Kefu Chai <k.chai@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH common 0/2] cmd: run: do not leave the command behind on a caller's timeout
Date: Wed, 21 Oct 2026 19:01:24 +0800 [thread overview]
Message-ID: <20261021110126.4024539-1-k.chai@proxmox.com> (raw)
Hi,
a colleague ran 'pvesm alloc' on an RBD pool whose placement groups
never became active. After 60 seconds the storage lock gave up and got
released, but 'rbd create' just kept running. As far as I can tell,
the lock's alarm handler dies inside run(), and run() only kills its
command on its own timeout or when a callback dies.
Patch 2 kills and reaps the command after run's eval if it's still
around. While looking into this I also noticed that run() cancels the
caller's alarm when it's done, so on shared LVM 'lvcreate' can run
without the lock's limit once 'vgs' ran before it. Patch 1 tries to
fix that.
My first attempt was a RAII-style guard that stops the child in
DESTROY. It worked, but once I let it send TERM first and wait a bit,
it needed signal masking and a few other things, which felt like too
much. Since run's body is wrapped in an eval that catches every die
anyway, a check after the eval seemed to do the same job with a lot
less code, so I went with that.
Things I didn't touch, as they behave like this today already:
- only the direct child gets killed, so commands behind a shell or
pipe might keep running
- a run timeout longer than the caller's alarm still delays it
- with noerr, a die from the caller's handler still gets swallowed
Both patches add tests to test/cmd-test.pl, and I tried the 'pvesm
alloc' case on a three node test cluster. I might well have missed
something, so any feedback is welcome, including whether the guard
would be the nicer way after all.
Kefu Chai (2):
cmd: run: do not cancel the caller's alarm
cmd: run: kill the command when run dies
src/PVE/Cmd.pm | 74 +++++++++++++++++++++---------------------------
test/cmd-test.pl | 68 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 100 insertions(+), 42 deletions(-)
--
2.47.3
next reply other threads:[~2026-10-21 11:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 11:01 Kefu Chai [this message]
2026-10-21 11:01 ` [PATCH common 1/2] cmd: run: do not cancel the caller's alarm Kefu Chai
2026-10-21 11:01 ` [PATCH common 2/2] cmd: run: kill the command when run dies Kefu Chai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261021110126.4024539-1-k.chai@proxmox.com \
--to=k.chai@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.