kalua: db: lock() be more atomic