Clean up stale locks when applying WAL in TransactionManager
Gitaly's TransactionManager
may fail to apply a log entry due to stale lock files on the disk. Stale lock files could be left behind if git update-ref
fails to update all of the references in the transaction due to a crash. These lock files will then prevent subsequent applications.
To allow TransactionManager
to apply log entries after a crash, it should clean up the stale lock files if it runs in to them and reapply the write. This is generally safe to do as the TransactionManager
is the single writer of a repository, so there should be no other git processes that rely on these locks. The only exception to this is the housekeeping which may write in the repository. The TransactionManager
should not clear lock files if housekeeping is running concurrently.