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.96) (envelope-from ) id 1wwDnv-001q3P-22 for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Aug 2026 07:00:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wwDnt-00EOEB-1h for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Aug 2026 07:00:10 +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.96) (envelope-from ) id 1wwDnt-00EOE2-0c for pgsql-hackers@lists.postgresql.org; Tue, 18 Aug 2026 07:00:10 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wwDnr-00000001Ltj-1KRW for pgsql-hackers@lists.postgresql.org; Tue, 18 Aug 2026 07:00:09 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-496bb7cdf51so52728045e9.2 for ; Tue, 18 Aug 2026 00:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787036405; x=1787641205; darn=lists.postgresql.org; h=content-transfer-encoding:content-type: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 :content-type; bh=3l84vUdFS4nT0IrIJmAoRuuUW5bnR1p32VfTHQHYJSE=; b=Xu9+TJFfVRh7nUXikjcVIE45Iosrx2FtnFFd5eeWDbCrzsihlyW8wVMrGjv+2Se9gg 49Lfv33HXVvLVx2z9sKRwd2jawBiklTMgDzIsYwkcFPVu6IVrDQ8H6b6tSQgxaknrXkC sMKLf7jSClvd1Ydt28N+MeYqJ/rEcM+29zVJgrozsfXJObSqQmuNZPwUX60FZafKDLqP uWsKLaXgUpDBAT/hLAaZalD/lRqLP3RPpqCpoeLnFgXSPvME36sz1UYOJueoOqNnH+aL 8ybvCRKR9q6ssJsLqPU8WOnPj8Dirlcepzw0E+olyJEWLGrELNHLcnxv5emPuFNKNP67 hZ6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787036405; x=1787641205; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3l84vUdFS4nT0IrIJmAoRuuUW5bnR1p32VfTHQHYJSE=; b=oU6iAKEo1qxFsljwwoC0nyFSURmhvuN5HXyDKfV0YApryASOXl1BKNAPJH9NLU1myQ xtkA1WuRpvA2trD/rG9XV04UJpJcXx5AmgSSqVlD+x/54YKp9IrbSOWh7Tp3aHvPQ0h5 mYwuJxr9oW4XeaDFSwmIM4EufrQXapJjTGpGxmV5XMzHsYtBMZDYi9uBwAQoj73z/u3R Py/dw6v9QGofWQM9LKj+pmtPn/0NcrBrdUkOVLu6oAlF+qzPZghOPJQCefnIZBd4Wh2O xh/LcQ3WolEG8LFMN/oEFOZT9J2UtVJWET034Qy3TcskA+OpXVGmuUBdhrtz7rK8widn kZzA== X-Forwarded-Encrypted: i=1; AHgh+Rpqpcte8yBwxyQ3YbsKh2u3abEHJJORnqjtcKaqvcRJOlcRmz21yzBjg4pNn/JCwY0j/E1urTdtAdJqVqO9@lists.postgresql.org X-Gm-Message-State: AOJu0Yz+UYFC1Ej2d8dM1CU29syTgGEOp1fJocYGUCsG0ccZXqzx2Tg4 rHTWqcpCMLbW/9YvB/efFA4nP57pzipuUm2Y76hxB/44MYx/iPFCYfLs X-Gm-Gg: AR+sD10WdmtdtqyxygfxRNQ8zeMv47iZTf/Xr53TPLo5fo8e7hQa8S8uBgeB3qAGnJt VfFgxTJmRjjSuGov5rdMVhjC06eyU9fWcApV+eDzQizQOuLCJlQ57VDQMzmzB9IwxEZwADVnDI7 Ai0/tEVsArncQrHybVZuU639qReflzg/gIv4Bg3pcOICg074BO0PZ7k+iReIp3q4Ucxwe+59BON GY+yUNlwxY4srzowPOO02prNPg0XPvnVVu9FCfqdFp2G3SqjapZnGomjNUGJG/Ddq6e3S3Bt7b6 EoW/gwy2WXeboVkOcLWYx5OgH37/TCRme6dV7FtT/YdklfTuv7cDDyTsloU3BPoix5kdWmKI0Nu SizEMQb8URD2oSJ7/OZhPEL3Ct/hkCluUlVvi/8gdmt+4t1owFMDNAK0xNFTwlHqGJrrug8te9l RmCF8tkiNvOVkwVivnc92+abGU4Q89K23/9WFr4N6RNeMaHfE1wbUFUFU1LVFf8tsh4p8F36OJQ w== X-Received: by 2002:a05:600c:1549:b0:496:bbce:fc with SMTP id 5b1f17b1804b1-4999fb6d563mr76901065e9.12.1787036403051; Tue, 18 Aug 2026 00:00:03 -0700 (PDT) Received: from [192.168.0.50] ([89.149.120.180]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-482a5a7c55bsm9286957f8f.20.2026.08.18.00.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Aug 2026 00:00:02 -0700 (PDT) Message-ID: <361531e2-52b5-499c-a126-815f277bbef2@gmail.com> Date: Tue, 18 Aug 2026 10:00:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: datachecksums: handle invalid and dropped databases during enable To: Daniel Gustafsson , Tomas Vondra Cc: Zsolt Parragi , "Jonathan Gonzalez V." , PostgreSQL Hackers References: <28CF6FD9-E1C4-4C04-8270-E3305AC46171@yesql.se> <87pl049996.fsf@gmail.com> <38651C03-7582-44AD-9895-5784755E9E7C@yesql.se> Content-Language: en-US From: Alexander Lakhin In-Reply-To: <38651C03-7582-44AD-9895-5784755E9E7C@yesql.se> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello Daniel and Tomas, 30.07.2026 14:02, Daniel Gustafsson wrote: >> On 30 Jul 2026, at 10:23, Jonathan Gonzalez V. wrote: >> Daniel Gustafsson writes: >> I've tested your patch and confirm that it fixed the issue > Thanks for review, pushed and backpatched. It looks like that that addition to test_checksums/001_basic.pl is not very stable on machines having slow storage. Buildfarm animal turaco (Raspberry Pi, presumably with SD card onboard) fails the test pretty reliably, e.g., [1], [2]: [21:37:30.016](0.002s) # issuing query 1 via background psql: CREATE TEMP TABLE holdme (a int); [21:37:30.024](0.009s) # results query 1: # { #   'stderr' => 'background_psql: QUERY_SEPARATOR 1: # ', #   'stdout' => 'background_psql: QUERY_SEPARATOR 1: # ' # } [21:37:47.284](17.259s) # die: error running SQL: 'psql::1: ERROR:  database "dropmeforce" is being accessed by other users # DETAIL:  There is 1 other session using the database.' # while running 'psql --no-psqlrc --no-align --tuples-only --quiet --dbname port=12278 host=/mnt/data/buildfarm/buildroot/tmp/n3IU4kJupg dbname='postgres' --file - --variable ON_ERROR_STOP=1' with sql 'DROP DATABASE dropmeforce WITH (FORCE);' at t/001_basic.pl line 163. [21:37:47.286](0.002s) 1..19 error running SQL: 'psql::1: ERROR:  database "dropmeforce" is being accessed by other users DETAIL:  There is 1 other session using the database.' while running 'psql --no-psqlrc --no-align --tuples-only --quiet --dbname port=12278 host=/mnt/data/buildfarm/buildroot/tmp/n3IU4kJupg dbname='postgres' --file - --variable ON_ERROR_STOP=1' with sql 'DROP DATABASE dropmeforce WITH (FORCE);' at t/001_basic.pl line 163. Probably, it's caused by the storage degradation (the test case was committed on 2026-07-28, but the first failure was produced on 2026-08-13) and the given test is just the most demanding (only this test fails there) for now, but I can reproduce such failures on Orange PI with SD card too, running 1-3 test instances simultaneously. With the diagnostic logging added: --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -3787,6 +3787,7 @@ CountOtherDBBackends(Oid databaseId, int *nbackends, int *nprepared)                         else                         {                                 (*nbackends)++; +fprintf(stderr, "!!!CountOtherDBBackends[%d]| tries: %d, proc-pid: %d\n", getpid(), tries, proc->pid);                                 if ((statusFlags & PROC_IS_AUTOVACUUM) &&                                         nautovacs < MAXAUTOVACPIDS)                                         autovac_pids[nautovacs++] = proc->pid; I can see the following counts when the test passes: ... !!!CountOtherDBBackends[129416]| tries: 45, proc-pid: 129391 !!!CountOtherDBBackends[129416]| tries: 46, proc-pid: 129391 !!!CountOtherDBBackends[129416]| tries: 47, proc-pid: 129391 But the count can also reach 50, then the test fails as below: ... 2026-08-18 06:01:56.058 UTC client backend[170284] 001_basic.pl FATAL:  terminating connection due to administrator command 2026-08-18 06:01:56.058 UTC client backend[170284] 001_basic.pl DETAIL:  Signal sent by PID 170453, UID 1001. 2026-08-18 06:01:56.058 UTC datachecksums worker[170446] FATAL: terminating connection due to administrator command 2026-08-18 06:01:56.058 UTC datachecksums worker[170446] DETAIL: Signal sent by PID 170453, UID 1001. 2026-08-18 06:01:56.071 UTC postmaster[169264] LOG:  background worker "datachecksums worker" (PID 170446) exited with exit code 1 !!!CountOtherDBBackends[170453]| tries: 1, proc-pid: 170284 !!!CountOtherDBBackends[170453]| tries: 2, proc-pid: 170284 ... !!!CountOtherDBBackends[170453]| tries: 47, proc-pid: 170284 !!!CountOtherDBBackends[170453]| tries: 48, proc-pid: 170284 !!!CountOtherDBBackends[170453]| tries: 49, proc-pid: 170284 2026-08-18 06:02:03.632 UTC client backend[170453] 001_basic.pl ERROR:  database "dropmeforce" is being accessed by other users 2026-08-18 06:02:03.632 UTC client backend[170453] 001_basic.pl DETAIL:  There is 1 other session using the database. 2026-08-18 06:02:03.632 UTC client backend[170453] 001_basic.pl STATEMENT:  DROP DATABASE dropmeforce WITH (FORCE); Backtrace of the stuck backend 170284:   Id   Target Id                                   Frame * 1    Thread 0x3fa7dd6020 (LWP 170284) "postgres" 0x0000003fa72ff1c4 in ?? () from /lib/riscv64-linux-gnu/libc.so.6 #0  0x0000003fa72ff1c4 in ?? () from /lib/riscv64-linux-gnu/libc.so.6 #1  0x0000003fa7308fa0 in ?? () from /lib/riscv64-linux-gnu/libc.so.6 #2  0x0000002abde863a6 in PGSemaphoreLock (sema=0x3fa46f3980) at pg_sema.c:320 #3  0x0000002abdf8a858 in LWLockAcquireOrWait (lock=0x3f9b6e6b80, mode=LW_EXCLUSIVE) at lwlock.c:1434 #4  0x0000002abdaaba08 in XLogFlush (record=188513088) at xlog.c:2874 #5  0x0000002abdaa1250 in RecordTransactionCommit () at xact.c:1544 #6  0x0000002abdaa2246 in CommitTransaction () at xact.c:2406 #7  0x0000002abdaa3150 in CommitTransactionCommandInternal () at xact.c:3254 #8  0x0000002abdaa3080 in CommitTransactionCommand () at xact.c:3215 #9  0x0000002abdb0ab44 in RemoveTempRelationsCallback (code=1, arg=0) at namespace.c:4708 #10 0x0000002abdf6290c in shmem_exit (code=1) at ipc.c:250 #11 0x0000002abdf6279a in proc_exit_prepare (code=1) at ipc.c:199 #12 0x0000002abdf626d0 in proc_exit (code=1) at ipc.c:112 #13 0x0000002abe1a2ab4 in errfinish (filename=0x2abe40ddd0 "postgres.c", lineno=3518, funcname=0x2abe40fd80 <__func__.6> "ProcessInterrupts") at elog.c:608 #14 0x0000002abdfab748 in ProcessInterrupts () at postgres.c:3518 #15 0x0000002abdfa7248 in ProcessClientReadInterrupt (blocked=true) at postgres.c:522 #16 0x0000002abdd40de2 in secure_read (port=0x2abe6ee580, ptr=0x2abe696df0 , len=8192) at be-secure.c:251 #17 0x0000002abdd4a47a in pq_recvbuf () at pqcomm.c:921 #18 0x0000002abdd4a56c in pq_getbyte () at pqcomm.c:967 #19 0x0000002abdfa6f0e in SocketBackend (inBuf=0x3fcb500e08) at postgres.c:376 #20 0x0000002abdfa71de in ReadCommand (inBuf=0x3fcb500e08) at postgres.c:499 #21 0x0000002abdfad88a in PostgresMain (dbname=0x2abe76ce48 "dropmeforce", username=0x2abe76ce28 "orangepi") at postgres.c:4878 #22 0x0000002abdfa2ffa in BackendMain (startup_data=0x3fcb501040, startup_data_len=24) at backend_startup.c:124 #23 0x0000002abde94d0c in postmaster_child_launch (child_type=B_BACKEND, child_slot=1, startup_data=0x3fcb501040, startup_data_len=24, client_sock=0x3fcb501098) at launch_backend.c:268 #24 0x0000002abde9b85a in BackendStartup (client_sock=0x3fcb501098) at postmaster.c:3627 #25 0x0000002abde98bb0 in ServerLoop () at postmaster.c:1728 #26 0x0000002abde984ba in PostmasterMain (argc=4, argv=0x2abe6ec9e0) at postmaster.c:1415 #27 0x0000002abdd53380 in main (argc=4, argv=0x2abe6ec9e0) at main.c:231 Thus, it's not the checksum worker preventing the DROP, but 001_basic.pl session. This seems similar to [3], though this time the animal and the code path are different. [1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=turaco&dt=2026-08-13%2021%3A07%3A46 [2] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=turaco&dt=2026-08-15%2019%3A27%3A11 [3] https://www.postgresql.org/message-id/ab4Gf2r-Bd6P7BiW%40paquier.xyz Best regards, Alexander