NetBSD Problem Report #57546

From www@netbsd.org  Thu Jul 27 12:45:55 2023
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 5822B1A9238
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 27 Jul 2023 12:45:55 +0000 (UTC)
Message-Id: <20230727124554.112A41A923A@mollari.NetBSD.org>
Date: Thu, 27 Jul 2023 12:45:54 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: pkg_add leaves a corrupted mess when interrupted
X-Send-Pr-Version: www-1.0

>Number:         57546
>Category:       pkg
>Synopsis:       pkg_add leaves a corrupted mess when interrupted
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 27 12:50:00 +0000 2023
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The NetBSD Foun
>Environment:
>Description:
Hitting ^C, or losing power, or crashing, while in the middle of pkg_add leaves a mess.

Same is probably true of pkg_delete.
>How-To-Repeat:
1. Run pkg_add on a large package.
2. Hit ^C or yank the power while it's running.
>Fix:
1. Create an intent log, e.g. a sqlite3 database that is itself updated with transactions.
2. Teach pkg_add/delete to separately update and execute the intent log -- `execute' here means add or delete files, run INSTALL or DEINSTALL scripts, and update the legacy pkgdb.  (And rebuild the legacy pkgdb from scratch if that part was interrupted, because I'm not confident in atomicity of Berkeley DB updates.)
3. Audit INSTALL and DEINSTALL scripts for idempotence.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.