Summary:
When postgres database is being created it also copy system postgres tables.
There are a lot of them and single raft replication is used to create copied tables.
But there 2 major steps that are being done while table is created:
1) CreateTableInMemory, which requires holding write lock on system catalog. It creates table and tablets info.
2) Add table to system catalog, which requires holding write lock on system tablet.
Before the diff both locks were acquired individually for each table.
After the diff both locks are acquired only once while database is being created.
The original goal was to fix test CDCSDKBeforeImageTest.TestHistoryRetentionWithNoExportConsistentSnapshotAndBeforeImage and several similar tests in TSAN.
Those tests fails because of timeout in create database.
Unfortunately after fixing issue with create database, those tests faced the issue with CreateCDCStream timeout.
If will be addressed by followup diffs, to avoid mixing different non-trivial fixes in a single diff.
Jira: DB-14388
Test Plan: Jenkins
Reviewers: zdrudi
Reviewed By: zdrudi
Subscribers: ybase
Tags: #jenkins-ready
Differential Revision: https://phorge.dev.yugabyte.com/D40498