On Wed, Jul 27, 2022 at 1:24 PM Ashutosh Sharma <ashu.coe...@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