Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIweZ-0004oP-Ev for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Aug 2022 18:30:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oIwdQ-0000PN-Uf for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Aug 2022 18:28:52 +0000 Received: from makus.postgresql.org ([72.32.157.229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIwZi-0001IN-0I for pgsql-hackers@lists.postgresql.org; Tue, 02 Aug 2022 18:25:02 +0000 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oIw2Z-0003nG-CJ for pgsql-hackers@lists.postgresql.org; Tue, 02 Aug 2022 17:50:54 +0000 Received: by mail-qk1-x72a.google.com with SMTP id b25so11158653qka.11 for ; Tue, 02 Aug 2022 10:50:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc; bh=IdLeSdowqUavtn3yjABLYHpv1im5tp4gV4JEVRiJSG8=; b=T9mxnNeHJUgOp/hN8YhKmq89z/rjxBQOffok8NwNBGmzDsBnFrSbKi0sBgom0pvPD/ W9yBHkBJ7OljXIQv00YwSjfZXCQdE/d/uJQjOLCM9N5Xfi9hl4Ff30Z6wVgolJ2dsiqa oZlcxoXB0Nu5MJhoX5bO2/2Oe8PIF6hVC+DO/fGvJhVhDT47uvPC1UyYKDnG0cj2Ni5K vHgACQpHw8g8oSZj5Ualxk68c44aAZRv7G0EA5yeAbs3GACACkYa9Xd6hPhl6N7zgHtX Xb8SheQakSYfqN7hfuZQlP+qFXk6SITiFVyNlTmYrC0WII14bvijYPH9raCbTaZ9hgzo 9C4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=IdLeSdowqUavtn3yjABLYHpv1im5tp4gV4JEVRiJSG8=; b=kC6Hm9jXop6H/Y0MsgPTabgHKmJ1CSBeXJqrzMmdbgnj4cKnBhbJEWCi1YYrLFDDv/ KcLPUWebKwDNyQnvDaAQQ3r9SfTM0hjVSakemK5do5jGGGMWRBy5cTQDt3uhEDV8dKV8 IJiu5phYDV2S4v4ewbZVCuAErK0y+0mqUVsamMis+tJbewsRX7dOzh8qGwHNqh/2xdd4 SMTTPhVp1dIxLrhswWx4wWqV+rqJz1pHLKYL+p17oRK6NWgUYqIRjjqE/kO3OszH7oxB nFrFhcVUMwa/+KpSxIa5VAMMATBb7b5rhAg/XGjuH0M0885o5oAyjy4r06YnynbE4cTF 8R7A== X-Gm-Message-State: AJIora+u0TSqAlPD63yrWzXW9liFOoocZIC2tMY+BfbW+nDpbF54qFGR tow6KxdecjfPVspWJ+ZenWkBtg== X-Google-Smtp-Source: AGRyM1sAQElmNTA9EVhpaSUMUO6I+FWPgzEAJQLTpx5GHtMcwNd6zF9G5KKpFoP02QlmtgryZHBIMQ== X-Received: by 2002:a05:620a:44d4:b0:6b6:229e:dc5b with SMTP id y20-20020a05620a44d400b006b6229edc5bmr15921681qkp.327.1659462646361; Tue, 02 Aug 2022 10:50:46 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id m26-20020ac866da000000b00339163a06fcsm1731868qtp.6.2022.08.02.10.50.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Aug 2022 10:50:45 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 4E5F280066A; Tue, 2 Aug 2022 12:50:44 -0500 (CDT) Date: Tue, 2 Aug 2022 12:50:43 -0500 From: Justin Pryzby To: Robert Haas Cc: Dilip Kumar , Andres Freund , Ashutosh Sharma , Maciek Sakrejda , Bruce Momjian , Alvaro Herrera , Andrew Dunstan , Heikki Linnakangas , pgsql-hackers@lists.postgresql.org Subject: Re: [Proposal] Fully WAL logged CREATE DATABASE - No Checkpoints Message-ID: <20220802175043.GA13682@telsasoft.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Mar 29, 2022 at 11:55:05AM -0400, Robert Haas wrote: > On Mon, Mar 28, 2022 at 3:08 PM Robert Haas wrote: > > smgrcreate() as we would for most WAL records or whether it should be > > adopting the new system introduced by > > 49d9cfc68bf4e0d32a948fe72d5a0ef7f464944e. I wrote about this concern > > over here: > > > > http://postgr.es/m/CA+TgmoYcUPL+WOJL2ZzhH=zmrhj0iOQ=iCFM0SuYqBbqZEamEg@mail.gmail.com > > > > But apart from that question your adaptations here look reasonable to me. > > That commit having been reverted, I committed v6 instead. Let's see > what breaks... There's a crash 2022-07-31 01:22:51.437 CDT client backend[13362] [unknown] PANIC: could not open critical system index 2662 (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 #1 0x00007efe27999801 in __GI_abort () at abort.c:79 #2 0x00005583891941dc in errfinish (filename=, filename@entry=0x558389420437 "relcache.c", lineno=lineno@entry=4328, funcname=funcname@entry=0x558389421680 <__func__.33178> "load_critical_index") at elog.c:675 #3 0x00005583891713ef in load_critical_index (indexoid=indexoid@entry=2662, heapoid=heapoid@entry=1259) at relcache.c:4328 #4 0x0000558389172667 in RelationCacheInitializePhase3 () at relcache.c:4103 #5 0x00005583891b93a4 in InitPostgres (in_dbname=in_dbname@entry=0x55838a50d468 "a", dboid=dboid@entry=0, username=username@entry=0x55838a50d448 "pryzbyj", useroid=useroid@entry=0, load_session_libraries=, override_allow_connections=override_allow_connections@entry=false, out_dbname=0x0) at postinit.c:1087 #6 0x0000558388daa7bb in PostgresMain (dbname=0x55838a50d468 "a", username=username@entry=0x55838a50d448 "pryzbyj") at postgres.c:4081 #7 0x0000558388b9f423 in BackendRun (port=port@entry=0x55838a505dd0) at postmaster.c:4490 #8 0x0000558388ba6e07 in BackendStartup (port=port@entry=0x55838a505dd0) at postmaster.c:4218 #9 0x0000558388ba747f in ServerLoop () at postmaster.c:1808 #10 0x0000558388ba8f93 in PostmasterMain (argc=7, argv=) at postmaster.c:1480 #11 0x0000558388840e1f in main (argc=7, argv=0x55838a4dc000) at main.c:197 while :; do psql -qh /tmp postgres -c "DROP DATABASE a" -c "CREATE DATABASE a TEMPLATE postgres STRATEGY wal_log"; done # Run this for a few loops and then ^C or hold down ^C until it stops, # and then connect to postgres and try to connect to 'a': postgres=# \c a 2022-07-31 01:22:51.437 CDT client backend[13362] [unknown] PANIC: could not open critical system index 2662 Unfortunately, that isn't very consistent, and you have have to run it a bunch of times... I don't know if it's an issue of any significance that CREATE DATABASE / ^C leaves behind a broken database, but it is an issue that the cluster crashes. While struggling to reproduce that problem, I also hit this warning, which may or may not be the same. I added an abort() after WARNING in aset.c to get a backtrace. WARNING: problem in alloc set PortalContext: bogus aset link in block 0x55a63f2f9d60, chunk 0x55a63f2fb138 Program terminated with signal SIGABRT, Aborted. #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 51 ../sysdeps/unix/sysv/linux/raise.c: No existe el archivo o el directorio. (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 #1 0x00007f81144f1801 in __GI_abort () at abort.c:79 #2 0x000055a63c834c5d in AllocSetCheck (context=context@entry=0x55a63f26fea0) at aset.c:1491 #3 0x000055a63c835b09 in AllocSetDelete (context=0x55a63f26fea0) at aset.c:638 #4 0x000055a63c854322 in MemoryContextDelete (context=0x55a63f26fea0) at mcxt.c:252 #5 0x000055a63c8591d5 in PortalDrop (portal=portal@entry=0x55a63f2bb7a0, isTopCommit=isTopCommit@entry=false) at portalmem.c:596 #6 0x000055a63c3e4a7b in exec_simple_query (query_string=query_string@entry=0x55a63f24db90 "CREATE DATABASE a TEMPLATE postgres STRATEGY wal_log ;") at postgres.c:1253 #7 0x000055a63c3e7fc1 in PostgresMain (dbname=, username=username@entry=0x55a63f279448 "pryzbyj") at postgres.c:4505 #8 0x000055a63c1dc423 in BackendRun (port=port@entry=0x55a63f271dd0) at postmaster.c:4490 #9 0x000055a63c1e3e07 in BackendStartup (port=port@entry=0x55a63f271dd0) at postmaster.c:4218 #10 0x000055a63c1e447f in ServerLoop () at postmaster.c:1808 #11 0x000055a63c1e5f93 in PostmasterMain (argc=7, argv=) at postmaster.c:1480 #12 0x000055a63be7de1f in main (argc=7, argv=0x55a63f248000) at main.c:197 I reproduced that by running this a couple dozen times in an interactive psql. It doesn't seem to affect STRATEGY=file_copy. SET statement_timeout=0; DROP DATABASE a; SET statement_timeout='60ms'; CREATE DATABASE a TEMPLATE postgres STRATEGY wal_log ; \c a \c postgres Also, if I understand correctly, this patch seems to assume that nobody is connected to the source database. But what's actually enforced is just that nobody *else* is connected. Is it any issue that the current DB can be used as a source? Anyway, both of the above problems are reproducible using a different database. |postgres=# CREATE DATABASE new TEMPLATE postgres STRATEGY wal_log; |CREATE DATABASE -- Justin