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 1psFHE-0004v6-PE for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Apr 2023 04:00:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1psFHD-00049Y-ML for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Apr 2023 04:00:07 +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 1psFHD-00048o-ED for pgsql-bugs@lists.postgresql.org; Fri, 28 Apr 2023 04:00:07 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1psFHA-005VFA-PQ for pgsql-bugs@lists.postgresql.org; Fri, 28 Apr 2023 04:00:06 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4ec8149907aso10307281e87.1 for ; Thu, 27 Apr 2023 21:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682654404; x=1685246404; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=xBH8ZJCB+S8X6Kem6+ZU6dRa6UEcClTNwu2+GZkU2ks=; b=cnHoj2GNlf+mcuzwAA3LAyKqk68dD2EXRJcliAha0QzDlgahZRD3Dn9KncLqCajFqG vlKMx81pwfRPHJP8SG8PTtJg19AW/RaacBprbf7IpsGTwABNXy+ra3/h6dAdc+mdx3IX P2h9EX+OtPZQ3VpDXTp/hXTXzV+0bL5Wij4xExwX2SaazKgot/sk09/LJnG2638H7NKD uwyUkFvz/CceNLW0WOc17GgP2xW80NYigYyXHTV8JcjcjOuqt4ZCZRI9aLOkR79lTXpO qEssbhwkM8Ms/Qw6Ceu5zRnf9CVhOb9mQqWBv8VM7W8WoA1H1qULB8QOemrWd/51Ukb+ 7z+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682654404; x=1685246404; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xBH8ZJCB+S8X6Kem6+ZU6dRa6UEcClTNwu2+GZkU2ks=; b=H/tFMv/j/aPqGy+AzXDG9K6deE4zONCI2R7ogTbztnzPjVpte2Tc+FB+ZA2H3Wjc6G h4PKvnzX1dVRK2bPHv3R/VJPh3gKpWLswQ0xETkOYUFDoSEayV2gNrvOJM7p8/s3wV8A EzHwM67xWhQeUawX18YiPHvbbOdvnjIyiOKMSkRQNU/GkGlJc20Q0vrwlH4/LTA08dLf nQE6xY+uknKmW4+0FN6j9DOHjIyWneotN1jAqrAdMXtGhJJsyqUUNnQ8BNwjL+76B5y4 zC/vNZi4E2Ge+jHbr1TkxanU2+53Z6MDF+pHLuBmHNvmbmjfY0SoQwDNnDKDSCccsGt1 sUsQ== X-Gm-Message-State: AC+VfDzWxwwMAMclqvmJhLQ9/h8Umfk7aQMAMmZMqKTkOaZwi8GBUojQ eQDRUU2jQrr6xAAjfXmGe0k= X-Google-Smtp-Source: ACHHUZ78g97Oezobt9AVynXsevlfanDidkZ0/OS9TbR7rr+fqNs3ZW/MIFS6dYpdSrJNnFRXbXsOOA== X-Received: by 2002:a19:f60a:0:b0:4eb:30f9:eeca with SMTP id x10-20020a19f60a000000b004eb30f9eecamr1051157lfe.28.1682654402910; Thu, 27 Apr 2023 21:00:02 -0700 (PDT) Received: from [1.0.0.7] ([178.155.28.115]) by smtp.gmail.com with ESMTPSA id t12-20020a19ad0c000000b004e7d6eb9cbfsm3160126lfc.190.2023.04.27.21.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Apr 2023 21:00:02 -0700 (PDT) Message-ID: <0d45c9c1-17a1-932f-3925-86484f150c94@gmail.com> Date: Fri, 28 Apr 2023 07:00:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: BUG #17804: Assertion failed in pg_stat after fetching from pg_stat_database and switching cache->snapshot Content-Language: en-US To: Kyotaro Horiguchi Cc: pgsql-bugs@lists.postgresql.org References: <20230224.160812.1001813717917457753.horikyota.ntt@gmail.com> <1836967a-9f78-aed8-1ff1-3351c504e8f0@gmail.com> <20230428.104100.1566874883906441360.horikyota.ntt@gmail.com> From: Alexander Lakhin In-Reply-To: <20230428.104100.1566874883906441360.horikyota.ntt@gmail.com> 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 Kyotaro-san, 28.04.2023 04:41, Kyotaro Horiguchi wrote: > Nonetheless, I'm a bit concerned about making a direct call to > pgstat_clear_snapshot() from the assign callback, it might be fine for > now, but I worry that it could an issue later on. > > So, how about just settin a trigger that causes a snapshot clearing > prior to the next use, like the attached? I'm agree with the change — it's still rather simple and fixes the issue. Maybe you would also find appropriate to update the comment for pgstat_get_stat_snapshot_timestamp(). Perhaps add something like?: Note that the snapshot may be cleared here, if requested. > As for the test, I can't come up with a better one, but I think the > comment should explain its intention more clearly. I'd hesitated to mention a crash in the comment because I've seen assertion failures only (and no crash with a non-assert build), so I thought that the test should illustrate the new behavior in the first place. But I'm not opposed to your comment change, maybe it's more prominent indeed. Thank you for the fix! Best regards, Alexander