Fix flaky test isolation2:pg_basebackup_with_tablespaces (#10509)
Here is the diff output of the test result. drop database some_database_without_tablespace; -DROP +ERROR: database "some_database_without_tablespace" is being accessed by other users +DETAIL: There is 1 other session using the database. drop tablespace some_basebackup_tablespace; -DROP +ERROR: tablespace "some_basebackup_tablespace" is not empty The reason is that after client connection to the database exits, the server needs some time (the process might be scheduled out soon, and the operation needs to content for the ProcArrayLock lock) to release the PGPROC in proc_exit()->ProcArrayRemove(). During dropdb() (for database drop), postgres will call CountOtherDBBackends() to see if there are still sessions that are using the database by checking proc->databaseId, and it will try at most 5 sec. This test quits the db connection of some_database_without_tablespace and then drops the database immediately. This should be mostly fine but if the system is in slow or in heavy load, this still could lead to test flakiness. This issue could be simulated using gdb. Let's poll until database drop commands succeeds for the affected database. It seems that drop database sql command could not be in transaction block so I could not use plpgsql to implement, instead I use dropdb utility and bash command to implement that. Reviewed-by: NAsim R P <pasim@vmware.com> (cherry picked from commit c8b00ac7)
Showing
想要评论请 注册 或 登录