Fix rare concurrency bug in lock acquisition by the logging package.