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 1nKCpx-000648-DN for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Feb 2022 05:26:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nKCpw-0008OI-A7 for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Feb 2022 05:26:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nKCpv-0008O8-Vn for pgsql-hackers@lists.postgresql.org; Wed, 16 Feb 2022 05:26:44 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nKCpt-0003Lu-9L for pgsql-hackers@postgresql.org; Wed, 16 Feb 2022 05:26:42 +0000 Received: by mail-pl1-x629.google.com with SMTP id z17so1137151plb.9 for ; Tue, 15 Feb 2022 21:26:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:message-id:to:cc:subject:from:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=kN/1BVs3aKd6opfaNnfLG0OUngVYz0fMFPphf/nTWhM=; b=LkhNEAln/3oOyRze/YPFr1eQZC8VKvDb3KZ8nEiz5ymm+YRiyfzA3aCQkfDTIlaajL OZ1KpghlaTKxRD9pBKude9YmYwxmQTO+POB8JlH/cothDaicCmvMeOE9jdCYCGT1RW55 kn/xXqNgqXxEavCWhPmsepVBtRPD+pUZRJg5/3VDybkz6cHK2sLsSPkG5zTDGg3wclN3 rakOKoqCcchiRctVw6ekLh3ros3pSJ+nzvEMsPhwAJyrqIAhFunowVaRgYcA27ljQrBE uD7YV2VI3bxaX9lGHeVM/qtA0UO7/oks6ARTmXPnUui6QVxZNmgF1LYsSpXipLjCmJWr 3AOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:to:cc:subject:from:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=kN/1BVs3aKd6opfaNnfLG0OUngVYz0fMFPphf/nTWhM=; b=cY9S/gKQIa3z6HifyhIXPBYFNh4SCwIuwybwkwV4GyQ4oBYD9f5fDyjOTN32MMHrrF YI26Ev4yeAFkEXIR+/QBPYIUI1ZxN8fFoDuND4YdGAJ1Ti06tZktCfZ0tD7kx6j1r6jt 486UXcEIjOwQAPWMsIRXCz0dlx/Wlqcc6D2uVnd1LodVk9VLhtr82kL8ZHvLfcdLHJi1 9NDkvf1zTLCqFsCV2o2m2TUv+anGUAKVtXId2p7e45Ua8vIwhweLu/aCeAo0AtpB9O9z o40TuASHe0sD9A8tQsfnUth8PuFhcbTHSIaxWrDqsyOdoNz5tCD4Ht+NygjCDVV+uAT2 ZGeA== X-Gm-Message-State: AOAM532DgujVUmtMI01WA3DM2rG5oXNkcWnooJOjRhiaV6xIL+mn8MSN NSy+nRi6fA9K7ZDeasqJC8U= X-Google-Smtp-Source: ABdhPJx3HBcqcECAAijZbRWr4r5qmn39rSGuH00+zTsNW2OprtFnVxsB0Ca+AjcbgaAyg1VsIICXNg== X-Received: by 2002:a17:902:b204:b0:14f:26a7:9f61 with SMTP id t4-20020a170902b20400b0014f26a79f61mr774495plr.97.1644989200170; Tue, 15 Feb 2022 21:26:40 -0800 (PST) Received: from localhost (KD036014041111.ppp-bb.dion.ne.jp. [36.14.41.111]) by smtp.gmail.com with ESMTPSA id hk13sm6313140pjb.30.2022.02.15.21.26.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 15 Feb 2022 21:26:39 -0800 (PST) Date: Wed, 16 Feb 2022 14:26:37 +0900 (JST) Message-Id: <20220216.142637.1918987197255698649.horikyota.ntt@gmail.com> To: andres@anarazel.de Cc: hlinnaka@iki.fi, pgsql-hackers@postgresql.org Subject: Re: Race conditions in 019_replslot_limit.pl From: Kyotaro Horiguchi In-Reply-To: <20220215235157.jknqi73c5scietxe@alap3.anarazel.de> References: <83b46e5f-2a52-86aa-fa6c-8174908174b8@iki.fi> <20220215235157.jknqi73c5scietxe@alap3.anarazel.de> User-Agent: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk At Tue, 15 Feb 2022 15:51:57 -0800, Andres Freund wrote in > I think what happened is that there was no WAL to receive between the start of > the primary and the $node_primary3->wait_for_catchup($node_standby3); > > Because the slot is created without reserving WAL that allows the primary to > remove the WAL segments without ever creating a slot based conflict. I think > that should be fixable by reserving the slot at creation time? Agreed. Doing this att all slot creation seems fine. > > and: > > > > https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=serinus&dt=2022-02-15%2011%3A00%3A08 > > > > # Failed test 'have walsender pid 3682154 > > # 3682136' > > # at t/019_replslot_limit.pl line 335. > > # '3682154 > > # 3682136' > > # doesn't match '(?^:^[0-9]+$)' > > > > The latter looks like there are two walsenders active, which confuses the > > test. > > Too bad there's no plain pid in the log_line_prefix. Looks like that used to be the > buildfarm default, and I haven't fixed that animals configuration... > > %c apparently is hex(process startup time).hex(pid) in hex, so we're looking > for 382f58... Confirmed by the slot name: > 2022-02-15 12:10:20.874 CET [620b8a1c.382f58:5] LOG: received replication command: CREATE_REPLICATION_SLOT "pg_basebackup_3682136" TEMPORARY PHYSICAL ( RESERVE_WAL) > which pg_basebackup builds using the backend pid: > replication_slot = psprintf("pg_basebackup_%d", (int) PQbackendPID(param->bgconn)); > > The logs for that pid are: > 2022-02-15 12:10:20.873 CET [620b8a1c.382f58:1] LOG: connection received: host=[local] > 2022-02-15 12:10:20.874 CET [620b8a1c.382f58:2] LOG: replication connection authorized: user=bf application_name=019_replslot_limit.pl > 2022-02-15 12:10:20.874 CET [620b8a1c.382f58:3] LOG: received replication command: SHOW data_directory_mode > 2022-02-15 12:10:20.874 CET [620b8a1c.382f58:4] STATEMENT: SHOW data_directory_mode > 2022-02-15 12:10:20.874 CET [620b8a1c.382f58:5] LOG: received replication command: CREATE_REPLICATION_SLOT "pg_basebackup_3682136" TEMPORARY PHYSICAL ( RESERVE_WAL) > 2022-02-15 12:10:20.874 CET [620b8a1c.382f58:6] STATEMENT: CREATE_REPLICATION_SLOT "pg_basebackup_3682136" TEMPORARY PHYSICAL ( RESERVE_WAL) > 2022-02-15 12:10:20.875 CET [620b8a1c.382f58:7] LOG: received replication command: IDENTIFY_SYSTEM > 2022-02-15 12:10:20.875 CET [620b8a1c.382f58:8] STATEMENT: IDENTIFY_SYSTEM > 2022-02-15 12:10:20.875 CET [620b8a1c.382f58:9] LOG: received replication command: START_REPLICATION SLOT "pg_basebackup_3682136" 0/600000 TIMELINE 1 > 2022-02-15 12:10:20.875 CET [620b8a1c.382f58:10] STATEMENT: START_REPLICATION SLOT "pg_basebackup_3682136" 0/600000 TIMELINE 1 > > Even though the node has log_disconnect = true, and other processes indeed log > their disconnection, there's no disconnect for the above session until the > server is shut down. Even though pg_basebackup clearly finished? Uh, huh? It seems to me so, too. > I guess it's conceivable that the backend was still working through process > shutdown? But it doesn't seem too likely, given that several other connections > manage to get through entire connect / disconnect cycles? Yes, but since postmaster seems thinking that process is gone. > > Has anyone looked into these yet? regards. -- Kyotaro Horiguchi NTT Open Source Software Center