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 1nDe0P-0006YE-4H for pgsql-hackers@arkaria.postgresql.org; Sat, 29 Jan 2022 03:02:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nDe0N-0006Qs-O4 for pgsql-hackers@arkaria.postgresql.org; Sat, 29 Jan 2022 03:02:23 +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 1nDe0N-0006Qj-D5 for pgsql-hackers@lists.postgresql.org; Sat, 29 Jan 2022 03:02:23 +0000 Received: from mail-yb1-xb30.google.com ([2607:f8b0:4864:20::b30]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nDe0K-0001a2-Fz for pgsql-hackers@lists.postgresql.org; Sat, 29 Jan 2022 03:02:23 +0000 Received: by mail-yb1-xb30.google.com with SMTP id j2so10768452ybu.0 for ; Fri, 28 Jan 2022 19:02:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FmNYmkl4R3mcu60wsiOiZPMjM1DbTEcS4scRFbRnLRM=; b=HgsPWdxz0lrgdrl/Nxj4RYc0fjKnn3w5UBYkqisRvn2Al/sNTnK9YJ6bz1NbPn94ZK WQ3E3aOCBw/1LjgPrOreXdPIA8YASDmSzoQ76GEM469DS/IQxB8v87r3rT6h9+6tF8hw ByXzphy+VBzUG0YRcErRz0/jReDfK7Vx/aN8fDFciJVcygiEWioOCa8xDqZ2ruaxBbwR ml9jJTfugZfiFFpzZz5twexjUG+59ELW8CeUYP46YjVvuvKd7muDu0higeeduGfbN/Qz b6WTy3h5nQ8KuLLgaWoY3U0oyE5EKql67fknW8kW3Emo6MZTQgFTmQ4efPF812mTbVLF umPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FmNYmkl4R3mcu60wsiOiZPMjM1DbTEcS4scRFbRnLRM=; b=gabVT7D+rYGIXZftn1FkNKkPH9oLZHNMVlhu1+8AdGFvPyQ8LRQOv2lrsCPlT393Vj 3fiko7nNUEdYFN4nyUKAbgucvWJsnov3I4kD5f+XIQJ40AC+4Bse3K6qYFhIVQzn5+IP izHa2NNZb4i1/PM2jsbegvdRENYIQuk2F4ZmYY5XVE5HmC+Pt1s+CnSgHEsdaTlbETNz k25BaI4qg1NpJ582NKKRIhwU6hwbSvwKJlk3sT3ksNBJBX87NCnaSe2IHyXGzvq4PxTP mXLGuZGbTNUKViCqNo99pIqDxi9BIqUXHJZ5xVAX2gF/2XCZiZq6B7iJHqpYCa1NtM7T B0hQ== X-Gm-Message-State: AOAM5322IorzFXGBppT1hIptV4HJjPeZeUiCPMCZF9fr41hy5fAQqBSn lDdpzLxdMhsTe2EJtLr+XySUoIa+50BjJyPG9gU= X-Google-Smtp-Source: ABdhPJzzWg5xgBaKsU9lUinRm4169kBoGS0Z71euKO9BRUTcxXj8rzi4RJbuiborZxsFIj/UsNUSRtZhUXOI9l3g0Fw= X-Received: by 2002:a25:4053:: with SMTP id n80mr16082676yba.661.1643425338531; Fri, 28 Jan 2022 19:02:18 -0800 (PST) MIME-Version: 1.0 References: <885288.1641420714@sss.pgh.pa.us> In-Reply-To: <885288.1641420714@sss.pgh.pa.us> From: Amit Kapila Date: Sat, 29 Jan 2022 08:32:08 +0530 Message-ID: Subject: Re: Bugs in pgoutput.c To: Tom Lane Cc: PostgreSQL Hackers , =?UTF-8?B?SG91LCBaaGlqaWUv5L6vIOW/l+adsA==?= Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jan 6, 2022 at 3:42 AM Tom Lane wrote: > > Commit 6ce16088b caused me to look at pgoutput.c's handling of > cache invalidations, and I was pretty appalled by what I found. > > * rel_sync_cache_relation_cb does the wrong thing when called for > a cache flush (i.e., relid == 0). Instead of invalidating all > RelationSyncCache entries as it should, it will do nothing. > > * When rel_sync_cache_relation_cb does invalidate an entry, > it immediately zaps the entry->map structure, even though that > might still be in use (as per the adjacent comment that carefully > explains why this isn't safe). I'm not sure if this could lead > to a dangling-pointer core dump, but it sure seems like it could > lead to failing to translate tuples that are about to be sent. > > * Similarly, rel_sync_cache_publication_cb is way too eager to > reset the pubactions flags, which would likely lead to failing > to transmit changes that we should transmit. > Are you planning to proceed with this patch? AFAICS, this is good to go. Yesterday, while debugging/analyzing one cfbot failure[1] with one of my colleagues for row filter patch [2], we have seen the problem due to the exact reason (second reason) you outlined here. After using your patch and adapting the row filter patch atop it we see problem got fixed. [1] - https://cirrus-ci.com/task/5450648090050560?logs=test_world#L3975 [2] - https://commitfest.postgresql.org/36/2906/ -- With Regards, Amit Kapila.