mirror of
https://github.com/git/git.git
synced 2024-09-27 06:23:26 +02:00
0068aa7946
It was reported that the reftable unit tests in t0032 fail with the
following assertion when running on top of NFS:
running test_reftable_stack_compaction_concurrent_clean
reftable/stack_test.c: 1063: failed assertion count_dir_entries(dir) == 2
Aborted
Setting a breakpoint immediately before the assertion in fact shows the
following list of files:
./stack_test-1027.QJBpnd
./stack_test-1027.QJBpnd/0x000000000001-0x000000000003-dad7ac80.ref
./stack_test-1027.QJBpnd/.nfs000000000001729f00001e11
./stack_test-1027.QJBpnd/tables.list
Note the weird ".nfs*" file? This file is maintained by NFS clients in
order to emulate delete-after-last-close semantics that we rely on in
the reftable code [1]. Instead of unlinking the file right away and
keeping it open in the client, the NFS client will rename it to ".nfs*"
and then delete that temporary file when the last reference to it gets
dropped. Quoting the NFS FAQ:
> D2. What is a "silly rename"? Why do these .nfsXXXXX files keep
> showing up?
>
> A. Unix applications often open a scratch file and then unlink it.
> They do this so that the file is not visible in the file system name
> space to any other applications, and so that the system will
> automatically clean up (delete) the file when the application exits.
> This is known as "delete on last close", and is a tradition among
> Unix applications.
>
> Because of the design of the NFS protocol, there is no way for a
> file to be deleted from the name space but still remain in use by an
> application. Thus NFS clients have to emulate this using what
> already exists in the protocol. If an open file is unlinked, an NFS
> client renames it to a special name that looks like ".nfsXXXXX".
> This "hides" the file while it remains in use. This is known as a
> "silly rename." Note that NFS servers have nothing to do with this
> behavior.
This of course throws off the assertion that we got exactly two files in
that directory.
The test in question triggers this behaviour by holding two open file
descriptors to the "tables.list" file. One of the references is because
we are about to append to the stack, whereas the other reference is
because we want to compact it. As the compaction has just finished we
already rewrote "tables.list" to point to the new contents, but the
other file descriptor pointing to the old version is still open. Thus we
trigger the delete-after-last-close emulation.
Furthermore, it was reported that this behaviour only triggers with
|
||
---|---|---|
.. | ||
basics_test.c | ||
basics.c | ||
basics.h | ||
block_test.c | ||
block.c | ||
block.h | ||
blocksource.c | ||
blocksource.h | ||
constants.h | ||
dump.c | ||
error.c | ||
generic.c | ||
generic.h | ||
iter.c | ||
iter.h | ||
LICENSE | ||
merged_test.c | ||
merged.c | ||
merged.h | ||
pq_test.c | ||
pq.c | ||
pq.h | ||
publicbasics.c | ||
reader.c | ||
reader.h | ||
readwrite_test.c | ||
record_test.c | ||
record.c | ||
record.h | ||
refname_test.c | ||
refname.c | ||
refname.h | ||
reftable-blocksource.h | ||
reftable-error.h | ||
reftable-generic.h | ||
reftable-iterator.h | ||
reftable-malloc.h | ||
reftable-merged.h | ||
reftable-reader.h | ||
reftable-record.h | ||
reftable-stack.h | ||
reftable-tests.h | ||
reftable-writer.h | ||
stack_test.c | ||
stack.c | ||
stack.h | ||
system.h | ||
test_framework.c | ||
test_framework.h | ||
tree_test.c | ||
tree.c | ||
tree.h | ||
writer.c | ||
writer.h |