Database reindexing should work for multiple databases
The database reindexing process needs to support running across multiple databases. This feature has a few shared models, both used to query index bloat information and track reindexing operations. Because some of these models are backed by views over the pg_catalog
tables, they'll have to be created on the database where the indexes live.
Reindexing uses a lease to ensure only one instance runs at a time. Once we physically split databases, we can probably use a separate lease for each db, and pass the appropriate connection to the reindexing to talk to the corresponding database.
Extracting this from into a separate issue from #336586 (closed) as this its own change separate from other failures coming from background migrations.