Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1svQrU-00F1ca-Ox for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Oct 2024 00:35:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1svQrS-0082Dp-2s for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Oct 2024 00:35:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1svQrR-0082Dh-NI for pgsql-hackers@lists.postgresql.org; Tue, 01 Oct 2024 00:35:29 +0000 Received: from mail-qv1-xf29.google.com ([2607:f8b0:4864:20::f29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1svQrN-001vbH-HH for pgsql-hackers@postgresql.org; Tue, 01 Oct 2024 00:35:29 +0000 Received: by mail-qv1-xf29.google.com with SMTP id 6a1803df08f44-6cb2aac40faso44436836d6.1 for ; Mon, 30 Sep 2024 17:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=postsubmeta.net; s=google; t=1727742925; x=1728347725; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=05StkWdDQQrHTkiyxCVdz0zJEu+gp+BgeUGPPgFuaY8=; b=XFTp50cXtD9rNCPRsB4EGKvcUqX3lNbpcuJcYLFVqog/ZAEp2dIml0GCNHML4Y+SM2 End5ayb+/3100VU4JHSocXfkDSq3XcaNcNycTarsc5AHCoV4hEzTNpUD5oavxDwBHo28 zIL7WItZUXEIWXB/JMDR/0RgZFi/Pv1aDKRUFpwpuZExU515Vb6Ic1b/IXL/bz6L2Fl3 jnNRktSM/9LX7idUw/Tyisk9eJzC/cMRnWiRynH+jUMAJbWIo37Akp8yAh8xPs/ZwzS/ AR0t7OgTUV9idpHMTnDl4z5nQ3VgoyGlbB8sU0aH2Fdy38dipDKUsgPRaWQogs0h1ZYr q4kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727742925; x=1728347725; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=05StkWdDQQrHTkiyxCVdz0zJEu+gp+BgeUGPPgFuaY8=; b=gu0Z5ZmFoLqLfGGtULNWzrj2dfLrrX1tVlIXM4iRqwjLfc/4d3JoKFoYohjMXoSOvI 6usGiy83PVFGNeFrSIWystwD0oBXNOvvhYCVt0cI19xD8G2POQBRLhqCkNtb1iOHgz9m Lu2/0jWycvdMTQy+xRuoz9MopZdHdSpfPlhC8I2VQlHuvCzCBG7SNgGSDFV6pxA3Re+6 g8hHrYENFFz4rHhc1TIFogrXAIC200KEa0G2AqX8sMKPv1gQxtYBODGg0up4hNJeQEWp ipQA7PpkxhrM7exJ5Nx6bcJJHdecjFP9/vRBdI7Q6DXnO5Al9F02IRkS+1Db6dpaOiZ+ DGdA== X-Forwarded-Encrypted: i=1; AJvYcCX6OBMkalX8KEOsHmvQ8/kBQNP6DjWoU0p2BaRG1M2WlFZTt83xv+qXy8pr0sCsYPILP1tGgrq3Xkj6NFNR@postgresql.org X-Gm-Message-State: AOJu0Yz/Lg22at0Pt18HaUyBFVOQgg6qVcFGs5gUG8CyyfL7C7a+EqAV zyGSo7DmmuWodbvLYqvpP+TEt7bFz8sZ1O11nZRrFipHpE5ziavtuGsLq1TXXxc= X-Google-Smtp-Source: AGHT+IEd4qIFm36Zoen6EYIp9IxqP5+h9F+DPEwVk0RT/OTWx+nSvjC9ht9SJeIAJHPjJ9JmHJgsmQ== X-Received: by 2002:a05:6214:226b:b0:6cb:4d72:15be with SMTP id 6a1803df08f44-6cb72913365mr22905286d6.5.1727742925146; Mon, 30 Sep 2024 17:35:25 -0700 (PDT) Received: from [172.16.6.11] ([142.198.103.162]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb3b68e7fesm44320876d6.132.2024.09.30.17.35.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Sep 2024 17:35:24 -0700 (PDT) Message-ID: Date: Mon, 30 Sep 2024 20:35:12 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pg_upgrade check for invalid databases To: Daniel Gustafsson , Tom Lane Cc: Nathan Bossart , PostgreSQL Hackers References: <1455756.1727708139@sss.pgh.pa.us> Content-Language: en-US From: Thomas Krennwallner In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 30/09/2024 17.29, Daniel Gustafsson wrote: >> On 30 Sep 2024, at 16:55, Tom Lane wrote: > >> TBH I'm not finding anything very much wrong with the current >> behavior... this has to be a rare situation, do we need to add >> debatable behavior to make it easier? > > One argument would be to make the checks consistent, pg_upgrade generally tries > to report all the offending entries to help the user when fixing the source > database. Not sure if it's a strong enough argument for carrying code which > really shouldn't see much use though. In general, I agree that this situation should be rare for deliberate DROP DATABASE interrupted in interactive sessions. Unfortunately, for (popular) tools that perform automatic "temporary database" cleanup, we could recently see an increase in invalid databases. The additional check for pg_upgrade was made necessary due to several unrelated customers having invalid databases that stem from left-over Prisma Migrate "shadow databases" [1]. We could not reproduce this Prisma Migrate issue yet, as those migrations happened some time ago. Maybe this bug really stems from a much older Prisma Migrate version and we only see the fallout now. This is still a TODO item. But it appears that this tool can get interrupted "at the wrong time" while it is deleting temporary databases (probably a manual Ctrl-C), and clients are unaware that this can then leave behind invalid databases. Those temporary databases do not cause any harm as they are not used anymore. But eventually, PG installations will be upgraded to the next major version, and it is only then when those invalid databases resurface after pg_upgrade fails to run the checks. Long story short: interactive DROP DATABASE interrupts are rare (they do exist, but customers are usually aware). Automation tools on the other hand may run DROP DATABASE and when they get interrupted at the wrong time they will then produce several left-over invalid databases. pg_upgrade will then fail to run the checks. [1] https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/shadow-database