From: "'Felix Moessbauer' via isar-users" <isar-users@googlegroups.com>
To: isar-users@googlegroups.com
Cc: jan.kiszka@siemens.com, Felix Moessbauer <felix.moessbauer@siemens.com>
Subject: [PATCH 1/4] fix(dpkg-build): make sstate updates of DEPLOY_DIR_DEB atomic
Date: Thu, 10 Sep 2026 16:01:58 +0200 [thread overview]
Message-ID: <20260910140201.250854-2-felix.moessbauer@siemens.com> (raw)
In-Reply-To: <20260910140201.250854-1-felix.moessbauer@siemens.com>
DEPLOY_DIR_DEB is qualified by DISTRO, DISTRO_ARCH and PN, but not by
MACHINE. All multiconfigs sharing DISTRO and DISTRO_ARCH therefore run
do_dpkg_build and do_deploy_deb of the very same recipe on one directory,
concurrently and without any mutual exclusion. testsuite's test_cross for
example builds mc:qemuarm-bookworm and mc:nanopi-neo-efi-bookworm, both
armhf, so both provide hello-isar and example-module-armmp.
sstate_clean() unlinks the debs listed in the manifest before
sstate_install() puts them back. A do_deploy_deb running in parallel can
therefore observe DEPLOY_DIR_DEB partially populated, remove exactly the
packages that are still there from isar-apt and add back only those, so
the remaining ones silently disappear from the repository.
Take a dedicated lock in both sstate_clean() and sstate_install() of
do_dpkg_build, and in do_deploy_deb, via the sstate-lockfile task flag.
DEPLOY_DIR_DEB is then either complete or empty for do_deploy_deb, never
partial. The lock lives next to, not inside, DEPLOY_DIR_DEB so that
sstate_clean_manifest() cannot sweep it away.
Fixes: 1182a45b ("fix(dpkg-build): deploy debs via shared sstate dir")
Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
meta/classes-recipe/dpkg-base.bbclass | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/meta/classes-recipe/dpkg-base.bbclass b/meta/classes-recipe/dpkg-base.bbclass
index 4a81787e..164f247e 100644
--- a/meta/classes-recipe/dpkg-base.bbclass
+++ b/meta/classes-recipe/dpkg-base.bbclass
@@ -18,6 +18,13 @@ inherit essential
# WORKDIR lifecycle.
DEPLOYDIR = "${WORKDIR}/deploy"
DEPLOY_DIR_DEB = "${DEPLOY_DIR}/isar-deb/${DISTRO}-${DISTRO_ARCH}/${PN}"
+# DEPLOY_DIR_DEB is not qualified by MACHINE, so all multiconfigs sharing
+# DISTRO and DISTRO_ARCH run do_dpkg_build and do_deploy_deb of the same recipe
+# on it, concurrently. Serialize the sstate clean/install of do_dpkg_build
+# against do_deploy_deb, so that the latter never sees a partially populated
+# directory. Keep the lock next to, not inside, DEPLOY_DIR_DEB so that
+# sstate_clean_manifest() cannot sweep it away.
+DEPLOY_DIR_DEB_LOCK = "${DEPLOY_DIR}/isar-deb/${DISTRO}-${DISTRO_ARCH}/${PN}.lock"
DEPENDS ?= ""
RPROVIDES ?= "${PROVIDES}"
@@ -207,6 +214,7 @@ python do_dpkg_build() {
do_dpkg_build[cleandirs] = "${DEPLOYDIR}"
do_dpkg_build[sstate-inputdirs] = "${DEPLOYDIR}"
do_dpkg_build[sstate-outputdirs] = "${DEPLOY_DIR_DEB}"
+do_dpkg_build[sstate-lockfile] = "${DEPLOY_DIR_DEB_LOCK}"
do_dpkg_build[network] = "${TASK_USE_NETWORK_AND_SUDO}"
do_dpkg_build[depends] = "${SCHROOT_DEP} base-apt:do_cache isar-apt:do_cache_config"
do_dpkg_build[postfuncs] += "dpkg_collect_debs"
@@ -232,7 +240,9 @@ deb_clean() {
done
fi
}
-# the clean function modifies isar-apt
+# the clean function modifies isar-apt. Do not add DEPLOY_DIR_DEB_LOCK here:
+# CLEANFUNCS also runs sstate_cleanall(), which takes that lock itself, and
+# flock() would deadlock on the nested acquisition.
do_clean[lockfiles] = "${REPO_ISAR_DIR}/isar.lock"
do_clean[network] = "${TASK_USE_SUDO}"
@@ -249,7 +259,7 @@ addtask deploy_deb after do_dpkg_build before do_build
do_deploy_deb[deptask] = "do_deploy_deb"
do_deploy_deb[rdeptask] = "do_deploy_deb"
do_deploy_deb[depends] += "isar-apt:do_cache_config"
-do_deploy_deb[lockfiles] = "${REPO_ISAR_DIR}/isar.lock"
+do_deploy_deb[lockfiles] = "${REPO_ISAR_DIR}/isar.lock ${DEPLOY_DIR_DEB_LOCK}"
do_deploy_deb[dirs] = "${S} ${DEPLOY_DIR_DEB}"
python do_devshell() {
--
2.55.0
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20260910140201.250854-2-felix.moessbauer%40siemens.com.
next prev parent reply other threads:[~2026-09-10 14:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 14:01 [PATCH 0/4] Fix various race conditions on multiconfig 'Felix Moessbauer' via isar-users
2026-09-10 14:01 ` 'Felix Moessbauer' via isar-users [this message]
2026-09-10 14:01 ` [PATCH 2/4] fix(dpkg-build): clean isar-apt by source package and arch 'Felix Moessbauer' via isar-users
2026-09-10 14:02 ` [PATCH 3/4] fix(dpkg-build): scan DEPLOY_DIR_DEB only once in do_deploy_deb 'Felix Moessbauer' via isar-users
2026-09-10 14:02 ` [PATCH 4/4] fix(dpkg-source): make sstate updates of DEPLOY_DIR_SRC atomic 'Felix Moessbauer' via isar-users
2026-09-15 8:31 ` [PATCH 0/4] Fix various race conditions on multiconfig Zhihang Wei
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=20260910140201.250854-2-felix.moessbauer@siemens.com \
--to=isar-users@googlegroups.com \
--cc=felix.moessbauer@siemens.com \
--cc=jan.kiszka@siemens.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox