[Qa-jenkins-scm] [jenkins.debian.net] 01/01: reproducible: use transaction to reliable prevent race conditions

Holger Levsen holger at moszumanska.debian.org
Fri Mar 27 19:22:32 UTC 2015


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit 675367e1fd73f2a117e459753a7db4d30277f59d
Author: Holger Levsen <holger at layer-acht.org>
Date:   Fri Mar 27 20:21:58 2015 +0100

    reproducible: use transaction to reliable prevent race conditions
---
 bin/reproducible_build.sh | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bin/reproducible_build.sh b/bin/reproducible_build.sh
index 9c74391..2b9c5d8 100755
--- a/bin/reproducible_build.sh
+++ b/bin/reproducible_build.sh
@@ -182,8 +182,12 @@ else
 	START=$(date +'%s')
 	DURATION=0
 	# mark build attempt
-	sqlite3 -init $INIT ${PACKAGES_DB} "REPLACE INTO schedule (package_id, date_scheduled, date_build_started) VALUES ('$SRCPKGID', '$SCHEDULED_DATE', '$DATE');"
-
+	RESULT=$(sqlite3 -init $INIT ${PACKAGES_DB} "BEGIN IMMEDIATE TRANSACTION; SELECT package_id, date_build_started FROM schedule WHERE package_id = '$SRCPKGID' AND date_build_started = ''; REPLACE INTO schedule (package_id, date_scheduled, date_build_started) VALUES ('$SRCPKGID', '$SCHEDULED_DATE', '$DATE'); ROLLBACK TRANSACTION;")
+	if [ -z "$RESULT" ] ; then
+		echo "Package build has just been started by another job, aborting."
+		echo "Warning, package ${SRCPACKAGE} in ${SUITE} on ${ARCH} is probably already building elsewhere, exiting. Please check $BUILD_URL and https://reproducible.debian.net/$SUITE/$ARCH/${SRCPACKAGE} for a different BUILD_URL..." | mail -s "race condition prevented" qa-jenkins-scm at lists.alioth.debian.org
+		exit 0
+	fi
 	RBUILDLOG=/var/lib/jenkins/userContent/rbuild/${SUITE}/${ARCH}/${SRCPACKAGE}_None.rbuild.log
 	echo "Starting to build ${SRCPACKAGE}/${SUITE} on $DATE" | tee ${RBUILDLOG}
 	echo "The jenkins build log is/was available at $BUILD_URL/console" | tee -a ${RBUILDLOG}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list