swift/test/unit/obj
Clay Gerrard 442cc1d16d Fix race in new partitions detecting new/invalid suffixes.
The assumption that we don't need to write an entry in the invalidations
file when the hashes.pkl does not exist turned out to be a premature
optimization and also wrong.

Primarily we should recognize the creation of hashes.pkl is the first
thing that happens in a part when it lands on a new primary.  The code
should be optimized toward the assumption of the most common disk state.

Also, in this case the extra stat calls to check if the hashes.pkl exists
were not only un-optimized - but introducing a race.

Consider the common case:

proc 1                         | proc 2
-------------------------------|---------------------------
a) read then truncate journal  |
b) do work                     | c) append to journal
d) apply "a" to index          |

The index written at "d" may not (yet) reflect the entry writen by proc
2 at "c"; however, it's clearly in the journal so it's easy to see we're
safe.

Adding in the extra stat call for the index existence check increases
the state which can effect correctness.

proc 1                        | proc 2
------------------------------|---------------------------
a) no index, truncate journal |
b) do work                    | b) iff index exists
                              | c) append to journal
d) apply (or create) index    |

If step "c" doesn't happen because the index does not yet exist - the
update is clearly lost.

In our case we'd skip marking a suffix as invalid when the hashes.pkl
does not exist because we know "the next time we rehash" we'll have to
os.listdir suffixes anyway.  But if another process is *currently*
rehashing (and has already done it's os.listdir) instead we've just
dropped an invalidation on the floor.

Don't do that.

Instead - write down the invalidation.  The running rehash is welcome to
proceed on outdated information - as long as the next pass will grab and
hash the new suffix.

Known-Issue(s):

If the suffix already exists there's an even chance the running rehash
will hash in the very update for which we want to invalidate the suffix,
but that's ok it's idempotent.

Co-Author: Pavel Kvasnička <pavel.kvasnicka@firma.seznam.cz>
Co-Author: Alistair Coles <alistair.coles@hpe.com>
Co-Author: Kota Tsuyuzaki <tsuyuzaki.kota@lab.ntt.co.jp>
Related-Change-Id: I64cadb1a3feb4d819d545137eecfc295389794f0
Change-Id: I2b48238d9d684e831d9777a7b18f91a3cef57cd1
Closes-Bug: #1651530
2017-01-23 16:09:43 +00:00
..
__init__.py Initial commit of Swift code 2010-07-12 17:03:45 -05:00
common.py Fix stats calculation in object-reconstructor 2016-12-12 21:26:54 -08:00
test_auditor.py Fix race in new partitions detecting new/invalid suffixes. 2017-01-23 16:09:43 +00:00
test_diskfile.py Fix race in new partitions detecting new/invalid suffixes. 2017-01-23 16:09:43 +00:00
test_expirer.py Replace 'assertTrue(a not in b)' with 'assertNotIn(a, b)' 2016-12-12 16:23:09 +07:00
test_reconstructor.py Move documented reclaim_age option to correct location 2017-01-13 03:10:47 +00:00
test_replicator.py Move documented reclaim_age option to correct location 2017-01-13 03:10:47 +00:00
test_server.py Fix race in new partitions detecting new/invalid suffixes. 2017-01-23 16:09:43 +00:00
test_ssync_receiver.py Merge "Prevent ssync writing bad fragment data to diskfile" 2016-10-14 23:29:29 +00:00
test_ssync_sender.py Fix stats calculation in object-reconstructor 2016-12-12 21:26:54 -08:00
test_ssync.py Fix stats calculation in object-reconstructor 2016-12-12 21:26:54 -08:00
test_updater.py Merge "Add test for object updater user-agent header" 2017-01-11 18:58:36 +00:00