refactor replicator_db_security to be more resilient