This PR fixes a race condition in recv() where the receiver is not properly notified by the listener and can cause unnecessary timeouts.
Register the condition to the notifications map before checking the database.
Acquire the condition before adding it to the map. Otherwise, the listener may notify it before the wait, and the notification would be lost, causing unnecessary sleep/timeout.
Also fixed the issue where test_singleton didn't clean up the test database.
This PR fixes a race condition in recv() where the receiver is not properly notified by the listener and can cause unnecessary timeouts.
Also fixed the issue where test_singleton didn't clean up the test database.