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 1rnNg3-00CzNR-Sn for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Mar 2024 19:02:12 +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 1rnNg2-00FdoZ-8Y for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Mar 2024 19:02:10 +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 1rnNg1-00FdoQ-S6 for pgsql-hackers@lists.postgresql.org; Thu, 21 Mar 2024 19:02:10 +0000 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rnNfx-005ijl-F2 for pgsql-hackers@postgresql.org; Thu, 21 Mar 2024 19:02:09 +0000 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5d8b519e438so875497a12.1 for ; Thu, 21 Mar 2024 12:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1711047725; x=1711652525; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=AjSLi2mEkQkpIQnI/yv9W+o8UHiM/WqjHg7ExlvtKuU=; b=EdlZ2ak0dEwZiaKBJlglNOVUsGbqEMpmzeW/2IZylUn4K7B/YoulgpMn8rFUlWSurq eBhqoE22p8f2i9Nmy6cfjmn9IgmKQMa6YlFg2mHfbhQoWJjHuNVxPdOMMMHjuxvLNRFw o3Qd2a7g60xCG+i94nPr4IBH5XeybeNBCt90T2yRQIv0n1JEtuHnmc3gpTZFUB1CAQFB j5PS/wh0Fw4niPGM2kN5s5JP6IAOj4O0wNJGOIKilag/Fek6Mc7bLSOk4R4ewYFQNxYt PUb9+7D7GQkMmki2PvMfTTl71LAA8Tcq73jKKnSuLXoYLLpl7g/zlD19KUoRstGYqXnB Uizw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047725; x=1711652525; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=AjSLi2mEkQkpIQnI/yv9W+o8UHiM/WqjHg7ExlvtKuU=; b=K5OcA28uvgro+qWhXfgQl5Wj5zTNr5oZJf+fUpZOGbccukmu/aWw4ZtfC58plJacAA suxeV0u2Qow036lWmM0VEVq0YBqaMYJeo12Zf2LVKaEXsqCMynAkZgNrXQNlwuf/x6eP 1TkNNVJdAr2at4GixRRtSl6D648PdrNbAf9bhu7FimFjgW519tk9JzDW5mnaC71jms9K qX3fiKSUnua3x2nJY70IdJQGRmN6ZpMZL8mbfKEJZabneQ0eO9P/vOipZUhsMyoPk8/r lnv1+34n/JAGFYYRvB3a0sO+z75UNfdkKMR3jrdJSyAaaqgjCgYVUywxfK8z+G3/sdlt YOqQ== X-Forwarded-Encrypted: i=1; AJvYcCUrAsLjFuKKUM8wE9Ma4JJbfxgFTWCjvRbyiS026nz6Ao/JCXeoQsk45pyfOVjh0AkAGmdH+SMZYVGL4/t+nYlcMQA5IpptoEIq+bg8 X-Gm-Message-State: AOJu0Yw4HQ43Wkw2uwfllIIvcObdy7iwdv0F9sA6tmuiiRtmK7CBkqds oVCLWCrmj68eCXDPCqz3ZBvmSUZLc633BAMf/jYhziI91CkNeLsS9W17EBW3lA== X-Google-Smtp-Source: AGHT+IE+QGLsENOJMacId0YYDZk3kBj5SK/U4ppZhAfZUhE77uFAdpSKYNvrQVtBpC+6DIIT+7NyGQ== X-Received: by 2002:a17:90a:de18:b0:29f:68f0:e9c5 with SMTP id m24-20020a17090ade1800b0029f68f0e9c5mr199188pjv.45.1711047725397; Thu, 21 Mar 2024 12:02:05 -0700 (PDT) Received: from jeff-laptop.lan (c-76-102-242-158.hsd1.ca.comcast.net. [76.102.242.158]) by smtp.gmail.com with ESMTPSA id t24-20020a17090ad15800b0029c78446eb4sm3961517pjw.24.2024.03.21.12.02.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:02:04 -0700 (PDT) Message-ID: Subject: Re: Comments on Custom RMGRs From: Jeff Davis To: Danil Anisimow Cc: Andres Freund , PostgreSQL Hackers Date: Thu, 21 Mar 2024 12:02:03 -0700 In-Reply-To: References: <20220512034010.4oqa76pasrulkw32@alap3.anarazel.de> <20220512234207.pwwp6q33f72byet2@alap3.anarazel.de> <0892cd00635c8bcd458de6d43d31cf61953da1b2.camel@j-davis.com> <727b0f3b48aec2a4f968bf11c6fa8ca6382b6cca.camel@j-davis.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2024-03-21 at 19:47 +0700, Danil Anisimow wrote: > [pgss_001.v1.patch] adds a custom resource manager to the > pg_stat_statements extension. Did you consider moving the logic for loading the initial contents from disk from pgss_shmem_startup to .rmgr_startup? > The rm_checkpoint hook allows saving shared memory data to disk at > each checkpoint. However, for pg_stat_statements, it matters when the > checkpoint occurred. When the server shuts down, pgss deletes the > temporary file of query texts. In other cases, this is unacceptable. > To provide this capability, a flags parameter was added to the > rm_checkpoint hook. The changes are presented in [rmgr_003.v2.patch]. Overall this seems fairly reasonable to me. I think this will work for similar extensions, where the data being stored is independent from the buffers. My biggest concern is that it might not be quite right for a table AM that has complex state that needs action to be taken at a slightly different time, e.g. right after CheckPointBuffers(). Then again, the rmgr is a low-level API, and any extension using it should be prepared to adapt to changes. If it works for pgss, then we know it works for at least one thing, and we can always improve it later. For instance, we might call the hook several times and pass it a "phase" argument. Regards, Jeff Davis