swift/swift
Alistair Coles aad02ad30d Fix race when consolidating new partition
Suffix hash invalidations in hashes.invalid can be lost when two
concurrent calls to get_hashes consolidate the hashes of a new
partition with no hashes.pkl:

- suffix S has been invalidated and is listed in hashes.invalid
- process X calls get_hashes when there is no existing hashes.pkl
- process X removes hashes.invalids file in consolidate_hashes
- process X calculates the hash of suffix S (note, process X has
  not yet written hashes.pkl)
- process Y invalidates suffix S, appends S to hashes.invalid, so the
  hash of suffix S *should* be recalculated at some point
- process Z calls get_hashes->consolidate_hashes, deletes hashes.invalid
  because there is still no hashes.pkl
- process Z fails
- process X writes hashes.pkl with stale hash value for suffix S
- the invalidation of S that was made by process Y is lost

The solution is to never remove hashes.invalid during consolidate_hashes
without first recording any invalid suffixes in hashes and writing hashes
to disk in hashes.pkl. This is already the behaviour when hashes.pkl
exists. The cost of an additional write to hashes.pkl, introduced by this
patch, is only incurred once, when get_hashes first encounters a
partition with no hashes.pkl.

Related-Change: Ia43ec2cf7ab715ec37f0044625a10aeb6420f6e3

Change-Id: I08c8cf09282f737103e580c1f57923b399abe58c
2017-05-15 12:24:01 -07:00
..
account Merge "py3: Fixes encoding and type error" 2016-09-05 13:18:24 +00:00
cli Rebalance with min_part_seconds_left > 0 2017-02-14 11:21:21 +01:00
common Container drive error results double space usage on rest drives 2017-04-12 09:25:54 +02:00
container Correct swift reraising of exception 2016-09-01 02:25:29 +00:00
locale Imported Translations from Zanata 2016-11-22 07:50:26 +00:00
obj Fix race when consolidating new partition 2017-05-15 12:24:01 -07:00
proxy Enable object server to return non-durable data 2016-09-16 11:40:14 +01:00
__init__.py Make pbr a build-time only dependency 2013-10-29 12:29:49 -07:00