Skip to content

consider abandoing locking in FileHistoryCache#writeObjectToFile() #4267

@vladak

Description

@vladak

There is a curious comment about locking in

// We have a problem that multiple threads may access the cache layer
// at the same time. Since I would like to avoid read-locking, I just
// serialize the write access to the cache file. The generation of the
// cache file would most likely be executed during index generation, and
// that happens sequentially anyway....
// Generate the file with a temporary name and move it into place when
// done, so it is not necessary to protect the readers for partially updated
// files...
final File output;
try {
output = File.createTempFile("ogtmp", null, dir);
CacheUtil.writeCache(object, output);
} catch (IOException ioe) {
throw new HistoryException("Failed to write history", ioe);
}
synchronized (lock) {

I think this pertains to the times when the history cache could be generated on the fly, however this is no longer the case (#3828), so I think this lock can be removed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions