Page MenuHomePhabricator

tags: take lock instead of wlock before writing hgtagsfnodes1 cache
ClosedPublic

Authored by pulkit on Tue, Sep 8, 10:12 AM.

Details

Summary

This cache is shared across stores and hence we should take store lock before
writing to it. Otherwise there will be race where one share with wlock is
writing to this cache and other share with wlock is trying to read it
simultaneously.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

pulkit created this revision.Tue, Sep 8, 10:12 AM
pulkit planned changes to this revision.Thu, Sep 10, 7:09 AM
This revision was not accepted when it landed; it landed in state Changes Planned.
This revision was automatically updated to reflect the committed changes.

This change may break compatibility with older clients. As written, if an old client and modern client write the tags cache file, they will obtain different locks and race to write the tags cache. If we want backwards compatibility, we need to take the store lock in addition to the working directory lock.