fix notify / prune order issue
lock the database