From patchwork Wed May 6 15:29:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2274 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1778081436; bh=Q70UswbR9i3ldHYmIyQ98ShoL34zRBOvVhA8YFoDf64=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=E6N+wYBXP5ykCNGZ5d8QNM696ySvPsxZo9CVuI5ILBL5lRe5loRf4vpfv1hPKohYR ONn68SLwc6rx5SjlhhKpFuPmMLIy36dELplo/Iqd1BPGCIPuvl2QCdaXfrvzGXNl1k yTEdhcdarakTHRCHxNV57Vrl/uYgb/yl5rQZi/l4= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F25C26A949 for ; Wed, 6 May 2026 09:30:36 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 2DRQf4aO7F8V for ; Wed, 6 May 2026 09:30:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1778081436; bh=Q70UswbR9i3ldHYmIyQ98ShoL34zRBOvVhA8YFoDf64=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=E6N+wYBXP5ykCNGZ5d8QNM696ySvPsxZo9CVuI5ILBL5lRe5loRf4vpfv1hPKohYR ONn68SLwc6rx5SjlhhKpFuPmMLIy36dELplo/Iqd1BPGCIPuvl2QCdaXfrvzGXNl1k yTEdhcdarakTHRCHxNV57Vrl/uYgb/yl5rQZi/l4= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DFAEC6A92E for ; Wed, 6 May 2026 09:30:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1778081435; bh=99/BgGrFE7PGkdUHDa9ZFo0cxDXpq+ccEnRXmZOTe8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NidyBIu1RrkAEMT3ZPEhJZ0/7xA8LP27ijrbPdt7mSBXq3HdDwowshuHyVKcwOGHv S4TuymQGuDfP2VWn7sWNVH8S/9NOXril1Aos8qx1V0QRs1XdnwPixOqLEpnE0VxuZ4 ORWtESFvdOk77rxTU+pmmFdALA8WiW0wFgGTiAlo= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 332E36A92E; Wed, 6 May 2026 09:30:35 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id gXdYNsgPEatO; Wed, 6 May 2026 09:30:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1778081431; bh=eCHDcPJbz7AvQlVGX8lOdZhnpC8t67xg3OXCMzatkus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KDs8CJZUONf05A9kFr4KtMKocmKwAWc0Wtr5RviPFojL4HcIVEUbxzyngLEfAsv0j CsR/4w1fl03PGtqd1YdyMraj0xxTigg1VH1eKJ8n/hbmQyQgRSMuvyErkidAvJyJtA WpDO0ii4ZQSXozLj+WztpT0kc/IuPCrjAG/GsuXw= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id C3D8E6A87B; Wed, 6 May 2026 09:30:30 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 6 May 2026 09:29:51 -0600 Message-ID: <20260506153006.529909-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260506153006.529909-1-sjg@u-boot.org> References: <20260506153006.529909-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2PB5QSM3VAP6A2MJI2USPRI6WS6EJI3M X-Message-ID-Hash: 2PB5QSM3VAP6A2MJI2USPRI6WS6EJI3M X-MailFrom: sjg@u-boot.org 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 CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 2/6] patman: Enable WAL mode for concurrent database access List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The SQLite database is opened with default settings, so a single writer holds an exclusive lock that blocks readers, and the default busy timeout is short enough that two patman invocations running at once trip 'database is locked'. Switch the connection to WAL journalling so readers and a writer can coexist across processes, set synchronous=NORMAL (the recommended pairing for WAL), and raise the busy timeout to 30 seconds to ride out brief contention. Document the new behaviour in patman.rst, including the .patman.db-wal/-shm sidecar files WAL creates so users know to copy them together when backing the database up by hand. Signed-off-by: Simon Glass --- tools/patman/database.py | 7 ++++++- tools/patman/patman.rst | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/patman/database.py b/tools/patman/database.py index 2d6e27ef6e7..2b05a6c4cfe 100644 --- a/tools/patman/database.py +++ b/tools/patman/database.py @@ -122,8 +122,13 @@ class Database: # pylint:disable=R0904 raise ValueError('Already open') if not os.path.exists(self.db_path): tout.warning(f'Creating new database {self.db_path}') - self.con = sqlite3.connect(self.db_path) + self.con = sqlite3.connect(self.db_path, timeout=30) self.cur = self.con.cursor() + # WAL lets readers and a writer coexist across processes; the busy + # timeout above rides out brief contention before raising 'database + # is locked' + self.cur.execute('PRAGMA journal_mode=WAL') + self.cur.execute('PRAGMA synchronous=NORMAL') self.is_open = True def close(self): diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst index 39fc04deec8..ef8e2e2025c 100644 --- a/tools/patman/patman.rst +++ b/tools/patman/patman.rst @@ -1465,6 +1465,16 @@ Patman stores series tracking, review and workflow state in a SQLite database (``.patman.db``) in the top-level git directory. The schema is versioned and auto-migrated on startup (currently at v10). +The connection is opened in WAL mode (``journal_mode=WAL``, +``synchronous=NORMAL``) with a 30-second busy timeout, which lets multiple +patman invocations share the database safely: concurrent readers do not block +each other, and a writer only briefly excludes other writers. This means it is +fine to run, for example, ``patman status`` in one terminal while a long +``patman review`` is running in another. WAL creates ``.patman.db-wal`` and +``.patman.db-shm`` sidecar files alongside the database; they are managed by +SQLite and removed on a clean close, so copy or sync all three together if you +back the database up by hand. + The database allows patman to track a patch series across multiple versions, recording which patches belong to each version and how they map to patchwork entries. This means patman can detect when a new