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 1oXyeJ-000467-N8 for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Sep 2022 05:39:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oXyeI-000582-Im for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Sep 2022 05:39:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oXyeI-00057t-5L for pgsql-hackers@lists.postgresql.org; Tue, 13 Sep 2022 05:39:54 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oXyeF-0008AO-8u for pgsql-hackers@postgresql.org; Tue, 13 Sep 2022 05:39:53 +0000 Received: by mail-qk1-x736.google.com with SMTP id u28so4699101qku.2 for ; Mon, 12 Sep 2022 22:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=systemguards-com-ec.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=HnEQMJ5z30Cg9mrrW/+2F7EicBg1asc088NgTmvXGVg=; b=IO16oRU9meKmyFLRMPwpUWH/n63GUgwgfbz4GVxLO/Kc0G9t0qn1siUjsmBQJbfXc0 ruFeYtQPrQGqyrPFW9TwEiuQpG2H3VpT4vqTneHdbWODLLUPDQDOlm/f8xCc5N4yFN3r iszPqb6otV5c9VVgg5LMI6PZ9u/ryS88y7xg5sCCymX2YCgqQbphhP+XNYzeDfYKSo/Y aTid0/TlvbsBdI2JmcYjYZTXUdTTT2+c2p6IUmeBej8FaammdtSn9Almha1pWdux7+2O UplMkAMb7t/7NMVJ+tTQrpzxwKJKKRgPA6Abyi5jdzoa0x+NxF47PHXpm83GbHQFtXEZ aSXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=HnEQMJ5z30Cg9mrrW/+2F7EicBg1asc088NgTmvXGVg=; b=GK0jE3Zsu+Y8HQB+S73ymg902+MVTU54LfyJ30zOzJPwR9palQ+nQnL21LD7EBms63 AMO/BAMP4z9AqW8K6CG2rizBOv/BjsLiGWxt3/rnpwaoikTCLNQNb7BQKG0+jPcqvJQ1 KbrRRsygZ5KroQtmL69rI5LchOTt6PilpusX3jNg/asIqTHxNIoA7v4tvNMzhSPpi9sT vzvB/tk8bpXDocS/gaQEf9YX2huJosZJEUqkE/Iv0AFBQdLvo37rsXVaeKPCwiK1m6sY R6//Ww1/AKpfOyxGGZKKaQdl4Rj1fwrZxEywDlbC/rAbc5TTBOz7edlWApy6zQoyumo2 UfOg== X-Gm-Message-State: ACgBeo2uGJ8GOCU816RaUZp91xoa44RPr+3KoK0iP4dUNyHCk7Qnz4Oe p3PV2dQSGtQRFJ3ttCCRGaZYGw== X-Google-Smtp-Source: AA6agR6bIcB7MrMSVHHWfWywSbHx0TqywWN4jhnZrav+AQYgWF1r4w3Hq/HPYp80UvSEWhJw8ZolaQ== X-Received: by 2002:a05:620a:17aa:b0:6ce:5fe3:1c35 with SMTP id ay42-20020a05620a17aa00b006ce5fe31c35mr2626747qkb.337.1663047589157; Mon, 12 Sep 2022 22:39:49 -0700 (PDT) Received: from ahch-to ([201.183.1.162]) by smtp.gmail.com with ESMTPSA id y25-20020a37f619000000b006cdd0939ffbsm8792075qkj.86.2022.09.12.22.39.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 22:39:48 -0700 (PDT) Date: Tue, 13 Sep 2022 00:39:45 -0500 From: Jaime Casanova To: Andres Freund Cc: pgsql-hackers@postgresql.org Subject: Re: START_REPLICATION SLOT causing a crash in an assert build Message-ID: References: <20220907193908.prfnxnt6diao2fli@awork3.anarazel.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="pouv4jkpuOypXm1L" Content-Disposition: inline In-Reply-To: <20220907193908.prfnxnt6diao2fli@awork3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --pouv4jkpuOypXm1L Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Sep 07, 2022 at 12:39:08PM -0700, Andres Freund wrote: > Hi, > > On 2022-09-06 18:40:49 -0500, Jaime Casanova wrote: > > I'm not sure what is causing this, but I have seen this twice. The > > second time without activity after changing the set of tables in a > > PUBLICATION. This crash happens after a reset of statistics for a slot replication > Can you describe the steps to reproduce? > bin/pg_ctl -D data1 initdb bin/pg_ctl -D data1 -l logfile1 -o "-c port=54315 -c wal_level=logical" start bin/psql -p 54315 postgres < Which git commit does this happen on? > just tested again on f5047c1293acce3c6c3802b06825aa3a9f9aa55a > > > gdb says that debug_query_string contains: > > > > """ > > START_REPLICATION SLOT "sub_pgbench" LOGICAL 0/0 (proto_version '3', publication_names '"pub_pgbench"')START_REPLICATION SLOT "sub_pgbench" LOGICAL 0/0 (proto_version '3', publication_names '"pub_pgbench"') > > """ > > > > attached the backtrace. > > > > > #2 0x00005559bfd4f0ed in ExceptionalCondition ( > > conditionName=0x5559bff30e20 "namestrcmp(&statent->slotname, NameStr(slot->data.name)) == 0", errorType=0x5559bff30e0d "FailedAssertion", fileName=0x5559bff30dbb "pgstat_replslot.c", > > lineNumber=89) at assert.c:69 > > what are statent->slotname and slot->data.name? > and the problem seems to be that after zero'ing the stats that includes the name of the replication slot, this simple patch fixes it... not sure if it's the right fix though... -- Jaime Casanova Director de Servicios Profesionales SystemGuards - Consultores de PostgreSQL --pouv4jkpuOypXm1L Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="fix_reset_stat_replslot.patch" diff --git a/src/backend/utils/activity/pgstat_replslot.c b/src/backend/utils/activity/pgstat_replslot.c index b77c05ab5f..db44d51b4c 100644 --- a/src/backend/utils/activity/pgstat_replslot.c +++ b/src/backend/utils/activity/pgstat_replslot.c @@ -65,6 +65,7 @@ pgstat_reset_replslot(const char *name) /* reset this one entry */ pgstat_reset(PGSTAT_KIND_REPLSLOT, InvalidOid, ReplicationSlotIndex(slot)); + namestrcpy(&slot->data.name, name); } /* --pouv4jkpuOypXm1L--