Re: [Proposal] Fully WAL logged CREATE DATABASE - No Checkpoints
Ashutosh Sharma <ashu.coek88@gmail.com>
On Wed, Dec 22, 2021 at 5:06 PM Dilip Kumar <dilipbalaut@gmail.com> wrote: > > On Wed, Dec 22, 2021 at 4:26 PM Ashutosh Sharma <ashu.coek88@gmail.com> wrote: > > >> Basically, ALTER TABLE SET TABLESPACE, will register the > >> SYNC_UNLINK_REQUEST for the table files w.r.t the old tablespace, but > >> those will get unlinked during the next checkpoint. Although the > >> files must be truncated during commit itself but unlink might not have > >> been processed until the next checkpoint. This is the explanation for > >> the behavior you found during your investigation, but I haven't looked > >> into the issue so I will do it latest by tomorrow and send my > >> analysis. > >> > >> Thanks for working on this. > > > > > > Yeah the problem here is that the old rel file that needs to be unlinked still exists in the old tablespace. Earlier, without your changes we were doing force checkpoint before starting with the actual work for the alter database which unlinked/deleted the rel file from the old tablespace, but that is not the case here. Now we have removed the force checkpoint from movedb() which means until the auto checkpoint happens the old rel file will remain in the old tablespace thereby creating this problem. > > One solution to this problem could be that, similar to mdpostckpt(), > we invent one more function which takes dboid and dsttblspc oid as > input and it will unlink all the requests which are w.r.t. the dboid > and tablespaceoid, and before doing it we should also do > ForgetDatabaseSyncRequests(), so that next checkpoint does not flush > some old request. I couldn't find the mdpostchkpt() function. Are you talking about SyncPostCheckpoint() ? Anyway, as you have rightly said, we need to unlink all the files available inside the dst_tablespaceoid/dst_dboid/ directory by scanning the pendingUnlinks list. And finally we don't want the next checkpoint to unlink this file again and PANIC so for that we have to update the entry for this unlinked rel file in the hash table i.e. cancel the sync request for it. -- With Regards, Ashutosh Sharma.
Commits
-
When using the WAL-logged CREATE DATABASE strategy, bulk extend.
- 3e63e8462f31 16.0 landed
- 576bb0fc9342 15.0 landed
-
Avoid using a fake relcache entry to own an SmgrRelation.
- 1b94f8f232f6 15.0 landed
- 76733b399c49 16.0 landed
-
Fix data-corruption hazard in WAL-logged CREATE DATABASE.
- 692df425b688 16.0 landed
- 811203d4aff5 15.0 landed
-
initdb: When running CREATE DATABASE, use STRATEGY = WAL_COPY.
- ad43a413c4f7 15.0 landed
-
Simplify a needlessly-complicated regular expression.
- c6863b858291 15.0 landed
-
In 020_createdb.pl, change order of command-line arguments.
- 3d067c53b26d 15.0 landed
-
Add new block-by-block strategy for CREATE DATABASE.
- 9c08aea6a309 15.0 landed
-
Fix replay of create database records on standby
- 49d9cfc68bf4 15.0 cited
-
Refactor code for reading and writing relation map files.
- 39f0c4bd670c 15.0 landed
-
Replace RelationOpenSmgr() with RelationGetSmgr().
- f10f0ae420ee 15.0 cited
-
Refactor the fsync queue for wider use.
- 3eb77eba5a51 12.0 cited