add ReleaseOnError and make acquire_lock and release_lock public