store: fix race in watcher_hub

Get the lock before modifying the global objects in the hub.

Fix #1758.