Fix a thread starvation issue

Fix an issue we investigated for a customer, where the database took too much time to respond due to thread starvation. What happened is that we had too much threads waiting to the database to be initialized, so we run out of threads to actually initialize the database. Now we do limit just for the first 5 threads asking to initialize a database, and returning 503 once we reach that limit.