Re: making relfilenodes 56 bits
Dilip Kumar <dilipbalaut@gmail.com>
From: Dilip Kumar <dilipbalaut@gmail.com>
To: Ashutosh Sharma <ashu.coek88@gmail.com>
Cc: Thomas Munro <thomas.munro@gmail.com>,
Robert Haas <robertmhaas@gmail.com>, Andres Freund <andres@anarazel.de>, Heikki Linnakangas <hlinnaka@iki.fi>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-07-27T08:11:16Z
Lists: pgsql-hackers
On Wed, Jul 27, 2022 at 1:24 PM Ashutosh Sharma <ashu.coek88@gmail.com> wrote: > > Some more comments: Note: Please don't top post. > == > > Shouldn't we retry for the new relfilenumber if "ShmemVariableCache->nextRelFileNumber > MAX_RELFILENUMBER". There can be a cases where some of the tables are dropped by the user and relfilenumber of those tables can be reused for which we would need to find the relfilenumber that can be resued. For e.g. consider below example: > > postgres=# create table t1(a int); > CREATE TABLE > > postgres=# create table t2(a int); > CREATE TABLE > > postgres=# create table t3(a int); > ERROR: relfilenumber is out of bound > > postgres=# drop table t1, t2; > DROP TABLE > > postgres=# checkpoint; > CHECKPOINT > > postgres=# vacuum; > VACUUM > > Now if I try to recreate table t3, it should succeed, shouldn't it? But it doesn't because we simply error out by seeing the nextRelFileNumber saved in the shared memory. > > postgres=# create table t1(a int); > ERROR: relfilenumber is out of bound > > I think, above should have worked. No, it should not, the whole point of this design is not to reuse the relfilenumber ever within a cluster lifetime. You might want to read this mail[1] that by the time we use 2^56 relfilenumbers the cluster will anyway reach its lifetime by other factors. [1] https://www.postgresql.org/message-id/CA%2BhUKG%2BZrDms7gSjckme8YV2tzxgZ0KVfGcsjaFoKyzQX_f_Mw%40mail.gmail.com > == > > <caution> > <para> > Note that while a table's filenode often matches its OID, this is > <emphasis>not</emphasis> necessarily the case; some operations, like > <command>TRUNCATE</command>, <command>REINDEX</command>, <command>CLUSTER</command> and some forms > of <command>ALTER TABLE</command>, can change the filenode while preserving the OID. > > I think this note needs some improvement in storage.sgml. It says the table's relfilenode mostly matches its OID, but it doesn't. This will happen only in case of system table and maybe never in case of user table. Yes, this should be changed. > postgres=# create table t2(a int); > ERROR: relfilenumber is out of bound > > Since this is a user-visible error, I think it would be good to mention relfilenode instead of relfilenumber. Elsewhere (including the user manual) we refer to this as a relfilenode. No this is expected to be an internal error because in general during the cluster lifetime ideally, we should never reach this number. So we are putting this check so that it should not reach this number due to some other computational/programming mistake. -- Regards, Dilip Kumar EnterpriseDB: http://www.enterprisedb.com
Commits
-
Fix typos in comments, code and documentation
- 33ab0a2a527e 16.0 cited
-
Increase width of RelFileNumbers from 32 bits to 56 bits.
- 05d4cbf9b6ba 16.0 landed
-
Move RelFileNumber declarations to common/relpath.h.
- 2f47715cc864 16.0 landed
-
Include RelFileLocator fields individually in BufferTag.
- 82ac34db2036 16.0 landed
-
Convert macros to static inline functions (buf_internals.h)
- 3ac88fddd92c 16.0 landed
-
Remove the restriction that the relmap must be 512 bytes.
- d8cd0c6c95c0 16.0 landed
-
Change internal RelFileNode references to RelFileNumber or RelFileLocator.
- b0a55e43299c 16.0 landed
-
Reorder subskiplsn in pg_subscription to avoid alignment issues.
- 79b716cfb7a1 15.0 cited
-
Fix DROP {DATABASE,TABLESPACE} on Windows.
- 4eb2176318d0 15.0 cited
-
Restructure smgr API as per recent proposal. smgr no longer depends on
- 87bd95638552 8.0.0 cited