Problem/Motivation
After solving the routing error thrown when trying to reinstall over an existing database (see parent issue) we are now able to re-install over an existing database.
Core modules are re-installed and we can change site settings instead of throwing the AlreadyInstalledException.
The task state is set to "install_base_system".
In install.core.inc we got the function install_verify_database_settings() that should check if the database connection is valid, but when breaking at this point, I can see that the core tables are already injected in the database by the Drupal service.
Proposed resolution
Add a check during the install task "database_verified" if the database is empty or not.
But this should be done before the core tables injection that occurs before install_verify_database_settings() check.