add scope_lock / static_scope_lock, shorten lock duration in
error_handle