From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 609751FF0C0 for ; Wed, 21 Oct 2026 13:01:37 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 96A66214DF; Wed, 21 Oct 2026 13:01:33 +0200 (CEST) From: Kefu Chai 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 Message-ID: <20261021110126.4024539-1-k.chai@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1792580489338 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.309 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: RFXPK7CEPXIHGCENO6AFIUBSI4VETIGT X-Message-ID-Hash: RFXPK7CEPXIHGCENO6AFIUBSI4VETIGT X-MailFrom: k.chai@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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