Possible timing issues when using setActiveConnection to an external database under normal Drupal 8 operation
In looking at the getConnections method closer you can pass it the $target and $key parameters directly and it will return a handle to the specified database.

$this-&gt;_db = \Drupal\Core\Database\Database::getConnection('default', 'notificationsdb');


This way you don't have to mess around with setting the active database.