From: Yiannis Marangos Date: Fri, 11 Apr 2014 15:58:57 GMT Subject: Re: [PATCH v7 2/2] Verify index file before we opportunistically update it Message-ID: <20140411155857.GA12742@abyss.hitronhub.home> In-Reply-To: <53479DFD.4020702@web.de> On Fri, Apr 11, 2014 at 09:47:09AM +0200, Torsten Bögershausen wrote: > 6. process A applies a commit: > - read the index into memory > - take the lock > - update the index file on disc > - release the lock So here we can have race condition. Maybe we should implement Duy's idea of verifying the sha1 in write_index()? > The new code works like this: > > 8. process B applies a commit: > - take the lock > - verifies tha the index file on disc has the same sha as the one read before > # And if not: What do we do? die() or retry() ? > - update the index file on disc > - release the lock IMO, we must never die() if we want to do opportunistic update and we should never retry because it's a bit expensive if we do opportunistic update. -- Yiannis