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 1v8b4a-003V9r-U6 for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Oct 2025 09:12:00 +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 1v8b4Y-00BweW-I8 for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Oct 2025 09:11:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v8b4Y-00BweN-8Y for pgsql-hackers@lists.postgresql.org; Tue, 14 Oct 2025 09:11:59 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v8b4W-0025bM-2b for pgsql-hackers@postgresql.org; Tue, 14 Oct 2025 09:11:58 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-46e52279279so36075885e9.3 for ; Tue, 14 Oct 2025 02:11:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760433115; x=1761037915; 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=KbzEyg+giyOW9mUF5umXbIh6qmtV3mON2CyPUXu+aQg=; b=l/Vzpm94/aoftqtvdTyWnh5PtEXXjQ9yflBBPU4Vw3EMdCsyYgVRoATjO88et4N3Ti FVCozabKs2FhElV7KhHEGXZTJBZ7FVmKOzI0q28+x2HnudhyMM68SQE7TEPr3P8wL80/ F7CbFYcZsvYzDXx7r0+g+pF66QnhcZDqexUfY5v4feyS/HiDid9Wv+cSnpuczZNrl2Cy MqP8BF3xteWXaZXypo+/OR9LhK4ZaQf4lJtM69mcAJ2LYRsTfPhih+dse4vA/q36VpGu ew27XEEVGgFQ/L+2DjmFb2+weROTiHdiPkWwhgBtCnNSWYnMz9GwaRV1sMO923+m9j6c 24ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760433115; x=1761037915; 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=KbzEyg+giyOW9mUF5umXbIh6qmtV3mON2CyPUXu+aQg=; b=Bn8v2IeBn8BqMhDMN8yIp3OdgujKAlbK1nVkKq/4gn3RDVHQggY8FXxP4Zq90dMxZ6 hf9akSdIb/Ju7YTOGs71vMvcWEd0AS+iYyQh2jXaT0fWTTHe6gl6FLfJWdkNg9day6dY Z+e9UKLC91cVrstlt7UmZB142AY40ppO7RAVCNhx6BS43VFB5Zns6CQEkk16ZewZs/kc HJFDMlmBYeFhzjvLxkKVGKWkFTF6sXLv8El/tHIxiJg8z3xkyrPr/6xfw4gSzqrk4hiS Lzxq6vu5WxpA0twAeN2AYmN03heCqH5G7A7cFzOMjrmPCAq/h/LAOgjiPFyF9xpLeWke dBrQ== X-Forwarded-Encrypted: i=1; AJvYcCUE5HovrJ5GtMPg5zqy2waZs1TCmr15kQBIswYdms3S+faSSaUMR7XDGZVk86UprglkYo9XFovcZOd2EgJ/@postgresql.org X-Gm-Message-State: AOJu0Yxot0KIAn5z90SZcurj+GvtbvIkJ+nlsgX7f27T8CPtG1xZg5S9 LTVjDw2U3JUQmbzz5GRZN/aDbb3SX6w7kFEn3JHs0tqtvur0KmU+t9tn X-Gm-Gg: ASbGncv8GjWoaJ3KDn6eKMmxAZ4T9oP3KgoFiHV4LRkpPGyvdQAItQdJxJwudIXYZbh QKfT4Pb7lsVKeG/eyRm9D3nldbewJvRhV7lCNkUUdDVztKOK/1PxMZ7RyeNJyyC3JOqOOpyNnwt jE5WUzgsC38+B0yStpXGJUGHoDSjcfUTh/DO8PFU25W3J8nTRU2papuTS4MLnkhs5EYQp7TFEnT d/H0MrLi95wPPpkH651n4vDx7F5IvmaFD4sP24FdWnHva++zKvueYNOtN9Bj5tG/nWkfegml2/W 2QctxVoB5RKxllIiiN3Iy9x+v+diSEGAU5FaS0F7esQqF2CmwXBxIoLdAgKsGi9U7Aqpy+5YUpw b6Wf6m+R+PzTxgHxyuQu1iMPCfxpEXw/kJKoO7uCxfIvx7Z95/7fI X-Google-Smtp-Source: AGHT+IENfSOkcgqo5gfvUzlQUvjocYgpDezXTm4aHbB9U/VJfAx5IZETzCjHbn4NWQWIbnzylMeH0g== X-Received: by 2002:a05:600c:83c9:b0:46f:b42e:edd0 with SMTP id 5b1f17b1804b1-46fb42eee2emr120169995e9.41.1760433115165; Tue, 14 Oct 2025 02:11:55 -0700 (PDT) Received: from [192.168.15.198] ([80.251.191.198]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fb489ad27sm229249015e9.15.2025.10.14.02.11.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Oct 2025 02:11:54 -0700 (PDT) Message-ID: Date: Tue, 14 Oct 2025 11:11:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Comments on Custom RMGRs To: Michael Paquier Cc: Jeff Davis , Robert Haas , Danil Anisimow , Andres Freund , PostgreSQL Hackers , Dean Rasheed , Yurii Rashkovskii References: <0892cd00635c8bcd458de6d43d31cf61953da1b2.camel@j-davis.com> <727b0f3b48aec2a4f968bf11c6fa8ca6382b6cca.camel@j-davis.com> <22e756affaad88b77a52d67cb532ed2a544f2e36.camel@j-davis.com> <1e2256b744836aeb485c61954e9d8272f80141a0.camel@j-davis.com> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 27/5/2024 20:20, Michael Paquier wrote: > Please note that I've been studying ways to have pg_stat_statements > being plugged in directly with the shared pgstat APIs to get it backed > by a dshash to give more flexibility and scaling, giving a way for > extensions to register their own stats kind. In this case, the flush > of the stats would be controlled with a callback in the stats > registered by the extensions, conflicting with what's proposed here. > pg_stat_statements is all about stats, at the end. I don't want this > argument to act as a barrier if a checkpoint hook is an accepted > consensus here, but a checkpoint hook used for this code path is not > the most intuitive solution I can think of in the long-term.Let me continue this thread. I wait for any kind of checkpoint cut-in machinery for extensions. Typically, when collecting knowledge about the instance state, we store it in an extension's owned database table, incurring the costs associated with transactional mechanics, tuple format overhead, and so on. Usually, we don't need MVCC or rollback; we have fixed-length data, and it would be better to store data in hash tables. These hash tables should survive instances' restarts and crashes - that's the only feature needed. The pg_stat_statements dumps its data to a file, but it is not reliable enough when we need consistent information, such as replication status or when logging update conflicts (see the Spock extension [1]). When we learn about query executions, we can't dump the hash table on each ExecutorEnd due to overhead, but we are okay with adding one more WAL record containing the hash table entry data - it may be done by the backend or by a separate background worker. So, the primary reason for us is to have a moment to store the extension's state on disk, keeping in mind that we have registered RMGR, which allows us to restore the full state using this disk file and WAL records. For me, the ideal place for such a hook is CheckPointGuts, right between the CheckPointBuffers call and fsyncs. I think that to demonstrate how this hook can work, the pg_stat_statements storage may need to be redesigned slightly. [1] https://github.com/pgEdge/spock -- regards, Andrei Lepikhov, pgEdge