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 1rAEVX-005Z9R-0S for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Dec 2023 19:21:31 +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 1rAEVU-000sDk-Mo for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Dec 2023 19:21:28 +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 1rAEVU-000sDc-Cw for pgsql-hackers@lists.postgresql.org; Mon, 04 Dec 2023 19:21:28 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rAEVR-00A67B-JM for pgsql-hackers@postgresql.org; Mon, 04 Dec 2023 19:21:27 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2c9f7fe6623so22986851fa.3 for ; Mon, 04 Dec 2023 11:21:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701717684; x=1702322484; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=cRiIJySn6jH/cb0JyfDaC0CAGKK2exIn286H9tlW8Io=; b=X8ebKHKn9C+tX37y142hC+N4st8WNaU7OMDbbiAoMj4KlwQAqr4o7w01KZzhkG8qtJ 2Mz/k2aJdt8y4UQ5+85FHySZPZh7YgL1DYXgb7Bu3WEuqaNs4UOzecEJVumtZivpweDO S0UKc14TxCJVLuaNHpAjm7KadE5nIsVVHhjI2Ry21iqiWZHpT3LgmGcsT4WAhDGV0ME5 Ry/MwM3KZ0s7UP1tdjbyO/uzWOmZgNibK0AkMINgbRy5ZUOHc3ci05QqH8TEwX57LIAW oA1SWOuv9KXbWrNamc/su96stpLmoJhCgiZ4XdeVJStkmQPiSFkAWl4aB4IKJXe2IPot zglQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701717684; x=1702322484; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cRiIJySn6jH/cb0JyfDaC0CAGKK2exIn286H9tlW8Io=; b=Ryw8xCKPwpCESPiFSCaSrA8SJkgJZK+7HsouSEZHwuCxS13azXH6qj2kisTgJ9eJ2f VL7DVtmI+Y2TeI5Mg6AxLkFHhi/vW10+c0qPSZs+yDWJdChzXFVPx30OcjBpQsEZBkRh 8lLJVHN+aetIr76dsUKgYW8QbWCosn2AUoSzG+Hx5A8KN7XHoqYd5kQ4cO6xlhbN0uxq vBC51DzXX8C9tvPsDs4IoBXUcb9Xi9rnPTijcqq7NwIgG8dQE4NKU/ZSqEcz9xd5CpzH A/u21UrLlj7cx4exvUZj4iRZ33N9v08G4yc2FG+OhraV6IwhigoncBCsDz2nrejk2W4f XVcA== X-Gm-Message-State: AOJu0YwcZTq9VERI75jmqw5qppVqnSwXBqCDdQK8dS/vaQuQ4qA8WBmH 0zZMqKVFtitwzSo0/4eQHOKErr5lcscZXpKJkvE= X-Google-Smtp-Source: AGHT+IGOSHjvFXKjzfiWKCfD3VWcwUT9+LeVHNgVgsc5Qg3e4eikOZlBIfZiumHu5Sch8T0EWQ+eEFXOxrkpsr8Ffes= X-Received: by 2002:a2e:b008:0:b0:2ca:fbd:3081 with SMTP id y8-20020a2eb008000000b002ca0fbd3081mr158549ljk.15.1701717684181; Mon, 04 Dec 2023 11:21:24 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Matthias van de Meent Date: Mon, 4 Dec 2023 20:21:12 +0100 Message-ID: Subject: Re: Extensible storage manager API - SMGR hook Redux To: Kirill Reshke Cc: pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 4 Dec 2023 at 17:51, Kirill Reshke wrote: > > So, 0002 patch uses the `get_tablespace` function, which searches Catalog to tablespace SMGR id. I wonder how `smgr_redo` would work with it? That's a very good point I hadn't considered in detail yet. Quite clearly, the current code is wrong in assuming that the catalog is accessible, and it should probably be stored in a way similar to pg_filenode.map in a file managed outside the buffer pool. > Is it possible to query the system catalog during crash recovery? As far as i understand the answer is "no", correct me if I'm wrong. Yes, you're correct, we can't access buffers like this during recovery. That's going to need some more effort. > Furthermore, why do we only allow tablespace to have its own SMGR implementation, can we have per-relation SMGR? Maybe we can do it in a way similar to custom RMGR (meaning, write SMGR OID into WAL and use it in crash recovery etc.)? AMs (and by extension, their RMGRs) that use Postgres' buffer pool have control over how they want to layout their blocks and files, but generally don't care about where those blocks and files are located, as long as they _can_ be retrieved. Tablespaces, however, describe 'drives' or 'storage pools' in which the tables/relations are stored, which to me seems to be the more logical place to configure the SMGR abstraction of how and where to store the actual data, as SMGRs manage the low-level relation block IO (= file accesses), and tablespaces manage where files are stored. Note that nothing prevents you from using one tablespace (thus different SMGR) per relation, apart from bloated catalogs and the superuser permissions required for creating those tablespaces. It'd be difficult to manage, but not impossible. Kind regards, Matthias van de Meent Neon (https://neon.tech)