Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uXmZu-00EJbU-58 for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Jul 2025 20:00:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uXmZq-002XLb-MJ for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Jul 2025 20:00:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uXmZq-002XLR-AB for pgsql-hackers@lists.postgresql.org; Fri, 04 Jul 2025 20:00:07 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uXmZo-005bJr-1H for pgsql-hackers@postgresql.org; Fri, 04 Jul 2025 20:00:06 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-553b544e7b4so1258397e87.3 for ; Fri, 04 Jul 2025 13:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751659202; x=1752264002; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=XCotS0e0WpyA9EKGAPDwq8TCxprRozAA8zC/V+Wpw0Q=; b=WcsjGpIcuGZuS1vLhvJOgMsVw8UHhQH8VAj3OGv0CwaJEIV90JiacsDximQnMmqV0c KosmQ2Vkis8veCWc3PeVvZO8EoLmagnfSRuPENY7KvanaHn0OL61l26xYPUFdWc5nGqR /ThsIwL/VZYVfSwbZzXEu/vteasUiXfELgnbiuBjAsrD4y5F1NJ33IEv4u+MBZe0+VU5 H1QnOQj8Owqr5PmHT31rI1hfRJ0A3VaHGksNQanQueosddRZzNkPjnBYyW7tZ28BQmEi DuehWSQZEwY1Kuzhw7tWRoJyq2IJ1rVODt8FZ4Nsc2Aph0+8hPf98acLd6h4wl3OdRKr Yalw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751659202; x=1752264002; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XCotS0e0WpyA9EKGAPDwq8TCxprRozAA8zC/V+Wpw0Q=; b=ODiYe46CCL8CDAJUxYWM/scQd41ooCAjFkDKOzA5vew5iHmdz+2yf163V1b7lZOjWv DV7ALnq9bWIP6sYlTY+TBhIBzY+HKFgsjq58GzKHSmk2U7hK58JjHYMIGmh1jikQYOt3 KAFk5BdNjdCdqyos3E3FTJQsN5JZUoLvbua7944JvXwT+WB07ws0t41OWt2ph3pMir3V 9o/64KuSz3jBxpNjbC8u/mGOrnCLUtMNVmOrhneKVMIU/TbpQ3nSqJ+fIRXhJZDZKwf9 oC4kd5UvJmVTyK2GRh/QAZUE+JB7j36jpO/Nt/oK9XQ8VFbOI/GXp64YLn81TAuJ2oQI AZQw== X-Gm-Message-State: AOJu0Yyf3Cb+ADefK4cA5949aRmx8CPz3/IREr1Fv/Ki/Zpw8NKVt8HZ PK6iJE7ZtKU84NF661kJTRVZXWYKV7a891hwrHL1mtO/BK2BMrs9SFmG X-Gm-Gg: ASbGncuRVdpWbP/NLJNTUPgcWKuRod/FqldamI2hPkgIFIBqCXaUxa2zLrERQdyWiMT BRiCpkLDGx2p4aAeGwnDCsbzzHNvSb5+uZmsgvEfykDGSwtBzXqeWhqLNvbH7o3Ivce29HTBgBF nlv7lDmVPvWfhduCcF7cTYzH9rf1RDUyo/SjeEpYK/1MkRzYQ4oLNl2ijw5Ez4jJEqtpNSsMag+ 4AdPEzCt+oCweovgDBGIZLBx2JGM/nXCJ1hountf7SCK2D7lfkn38sBoFoSlsfwEq851REXyjyT 8The7nuRCYXUrU5mhAE6W28KZKaGKJqOCTe6uk/j+/2FTWWyXOKGlKAVcwBr+Ge9 X-Google-Smtp-Source: AGHT+IE8t8+F/XDJW5m3UVQf+kuEKqrHSyE/LLc60DZybDjV22gw1aersdoMHmv4mcmTrqrVXdIWKw== X-Received: by 2002:a05:6512:3d02:b0:553:aa60:faff with SMTP id 2adb3069b0e04-557a1ec0954mr854597e87.23.1751659202132; Fri, 04 Jul 2025 13:00:02 -0700 (PDT) Received: from [192.168.0.50] ([89.149.68.212]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-556383d8d35sm334978e87.71.2025.07.04.13.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 13:00:01 -0700 (PDT) Message-ID: Date: Fri, 4 Jul 2025 23:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: stats.sql might fail due to shared buffers also used by parallel tests To: Shlok Kyal Cc: pgsql-hackers , Andres Freund , Melanie Plageman References: Content-Language: en-US From: Alexander Lakhin In-Reply-To: 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 Shlok, 03.07.2025 09:54, Shlok Kyal wrote: > I have also encountered a similar buildfarm failure [1]. > > | 1/1 + subscription 142 ms FAIL > 1/1 postgresql:regress / regress/regress ERROR 284.85s exit status 1 > > diff --strip-trailing-cr -U3 > c:/build-farm-local/buildroot/HEAD/pgsql/src/test/regress/expected/subscription.out > c:/build-farm-local/buildroot/HEAD/pgsql.build/testrun/regress/regress/results/subscription.out > --- c:/build-farm-local/buildroot/HEAD/pgsql/src/test/regress/expected/subscription.out > 2025-06-28 20:13:02 +0900 > +++ c:/build-farm-local/buildroot/HEAD/pgsql.build/testrun/regress/regress/results/subscription.out > 2025-06-28 20:35:21 +0900 > @@ -70,7 +70,7 @@ > SELECT :'prev_stats_reset' < stats_reset FROM > pg_stat_subscription_stats WHERE subname = 'regress_testsub'; > ?column? > ---------- > - t > + f > (1 row) Thank you for your attention to this! Yes, I also noticed that failure, but could not reproduce it yet. > So according to me, I suspect the following causes > 1) The time difference between 'prev_stats_reset' and current > 'stats_reset' value is less than 1 microseconds. > 'stats_reset' is of type 'timestamp with time zone' and the content of > it is like: '2025-06-30 21:01:07.925253+05:30'. So if the time > difference between 'prev_stats_reset' and current 'stats_reset' is > less than 1 microseconds. The query 'SELECT :'prev_stats_reset' < > stats_reset FROM pg_stat_subscription_stats WHERE subname = > 'regress_testsub'' might return 'false' instead of 'true'. > But I was not able to reproduce such a scenario after multiple > testing. Even in high end machines, it takes at least a few > microseconds. Also there are multiple cases where we did similar > timestamp comparison in 'stats.sql' as well. And, I didn't find any > other failure related to such case. So, I feel this is not possible. Did you try that on Windows (hamerkop is a Windows animal)? IIUC, GetCurrentTimestamp() -> gettimeofday() implemented on Windows via GetSystemTimePreciseAsFileTime(), and it has 100ns resolution, according to [1]. I tried it on a Windows VM and saw the following numbers: SELECT :'prev_stats_reset' < stats_reset, :'prev_stats_reset', stats_reset FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub';  ?column? |              ?column?               | stats_reset ----------+-------------------------------------+-------------------------------------  t        | Fri Jul 04 11:46:10.224323 2025 PDT | Fri Jul 04 11:46:10.224975 2025 PDT  (1 row) that is, the difference is about 600 ns — if I could make the VM 6x faster or run the test on a bare metal, maybe I'd get the test failed. Although the overall duration of the subscription doesn't differ much: My VM: # parallel group (2 tests):  subscription publication ok 164       + publication                               806 ms ok 165       + subscription                              210 ms vs hamerkop: # parallel group (2 tests):  subscription publication ok 164       + publication                              2383 ms not ok 165   + subscription                              142 ms So probably the failure is caused by something else. > 2) pg_stat_reset_subscription_stats(oid) function did not reset the stats. > We have a shared hash 'pgStatLocal.shared_hash'. If the entry > reference (for the subscription) is not found while executing > 'pg_stat_reset_subscription_stats(oid)'. It may not be able to reset > the stats. Maybe somehow this shared hash is getting dropped.. > Also, it could be failing due to the same reason as Alexander has I don't think 2) is relevant here, because shared buffers shouldn't affect subscription's statistics. [1] https://stackoverflow.com/questions/4444090/measuring-time-with-a-resolution-of-microseconds-in-c Best regards. Alexander