git/builtin
Jeff Hostetler 6692d45477 fsmonitor: fix race seen in t7527
Fix racy tests in t7527 by forcing the use of cookie files during all
types of queries.  There were originaly observed on M1 macs with file
system encryption enabled.

There were a series of simple tests, such as "edit some files" and
"create some files", that started the daemon with GIT_TRACE_FSMONITOR
enabled so that the daemon would emit "event: <path>" messages to the
trace log.  The test would make worktree modifications and then grep
the log file to confirm it contained the expected trace messages.
The greps would occasionally racily-fail.  The expected messages
were always present in the log file, just not yet always present
when the greps ran.

NEEDSWORK: One could argue that the tests should use the `test-tool
fsmonitor-client query` and search for the expected pathnames in the
output rather than grepping the trace log, but I'll leave that for a
later exercise.

The racy tests called `test-tool fsmonitor-client query --token 0`
before grepping the log file.  (Presumably to introduce a small delay
and/or to let the daemon sync with the file system following the last
modification, but that was not always sufficient and hence the race.)

When the query arg is just "0", the daemon treated it as a V1
(aka timestamp-relative request) and responded with a "trivial
response" and a new token, but without trying to catch up to the
the file system event stream.  So the "event: <path>" messages
may or may not yet be in the log file when the grep commands
started.

FWIW, if the tests had sent `--token builtin:0:0` instead, it would
have forced a slightly different code path in the daemon that would
cause the daemon to use a cookie file and let it catch up with the
file system event stream.  I did not see any test failures with this
change.

Instead of modifying the test, I updated the fsmonitor--daemon to
always use a cookie file and catch up to the file system on any
query operation, regardless of the format of the request token.
This is safer.

FWIW, I think the effect of the race was limited to the test.
Commands like `git status` would always do a full scan when getting a
trivial response.  The fact that the daemon was slighly behind the
file system when it generated the response token would cause a second
`git status` to get a few extra paths that the client would have to
examine, but it would not be missing paths.

FWIW, I also think that an earlier version of the code always did
the cookie file for all types of queries, but it was optimized out
during a round of reviews or rework and we didn't notice the race.

Signed-off-by: Jeff Hostetler <jeffhostetler@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-12-02 09:07:48 +09:00
..
add.c add: remove support for git-legacy-stash 2022-01-27 18:00:15 -08:00
am.c Merge branch 'ab/date-mode-release' 2022-02-25 15:47:36 -08:00
annotate.c
apply.c
archive.c use xopen() to handle fatal open(2) failures 2021-08-25 14:39:08 -07:00
bisect--helper.c i18n: remove from i18n strings that do not hold translatable parts 2022-02-04 13:58:28 -08:00
blame.c Merge branch 'ja/i18n-common-messages' 2022-02-25 15:47:35 -08:00
branch.c Merge branch 'gc/branch-recurse-submodules' 2022-02-18 13:53:29 -08:00
bugreport.c hook-list.h: add a generated list of hooks, like config-list.h 2021-09-27 09:44:54 -07:00
bundle.c Merge branch 'ab/bundle-remove-verbose-option' 2021-10-03 21:49:20 -07:00
cat-file.c cat-file: s/_/-/ in typo'd usage_msg_optf() message 2022-01-12 10:12:39 -08:00
check-attr.c
check-ignore.c
check-mailmap.c
check-ref-format.c
checkout--worker.c pkt-line.[ch]: remove unused packet_read_line_buf() 2021-10-15 13:09:40 -07:00
checkout-index.c checkout-index: integrate with sparse index 2022-01-13 13:49:45 -08:00
checkout.c Merge branch 'js/short-help-outside-repo-fix' 2022-02-18 13:53:30 -08:00
clean.c Merge branch 'vd/sparse-clean-etc' 2022-02-17 16:25:05 -08:00
clone.c Merge branch 'js/apply-partial-clone-filters-recursively' 2022-02-25 15:47:35 -08:00
column.c column: fix parsing of the '--nl' option 2021-08-26 14:36:27 -07:00
commit-graph.c Merge branch 'ab/ignore-replace-while-working-on-commit-graph' 2021-11-01 13:48:08 -07:00
commit-tree.c use xopen() to handle fatal open(2) failures 2021-08-25 14:39:08 -07:00
commit.c Merge branch 'ab/date-mode-release' 2022-02-25 15:47:36 -08:00
config.c urlmatch.[ch]: add and use URLMATCH_CONFIG_INIT 2021-10-01 14:22:51 -07:00
count-objects.c i18n: remove from i18n strings that do not hold translatable parts 2022-02-04 13:58:28 -08:00
credential-cache--daemon.c
credential-cache.c credential-cache: check for windows specific errors 2021-09-14 09:30:54 -07:00
credential-store.c Use a better name for the function interpolating paths 2021-07-26 12:17:16 -07:00
credential.c doc: fix git credential synopsis 2021-10-28 09:57:09 -07:00
describe.c i18n: turn even more messages into "cannot be used together" ones 2022-01-05 13:31:00 -08:00
diff-files.c
diff-index.c diff-index: restore -c/--cc options handling 2021-09-07 11:11:35 -07:00
diff-tree.c i18n: refactor "foo and bar are mutually exclusive" 2022-01-05 13:29:23 -08:00
diff.c builtin/diff.c: fix "git-diff" usage string typo 2022-02-02 11:30:53 -08:00
difftool.c i18n: factorize more 'incompatible options' messages 2022-02-04 13:58:28 -08:00
env--helper.c
fast-export.c i18n: fix some misformated placeholders in command synopsis 2022-02-04 13:58:28 -08:00
fast-import.c date API: create a date.h, split from cache.h 2022-02-16 09:40:00 -08:00
fetch-pack.c
fetch.c Merge branch 'ja/i18n-common-messages' 2022-02-25 15:47:35 -08:00
fmt-merge-msg.c merge: allow to pretend a merge is made into a different branch 2021-12-20 14:55:02 -08:00
for-each-ref.c for-each-ref: delay parsing of --sort=<atom> options 2021-10-20 14:33:07 -07:00
for-each-repo.c builtin/for-each-repo: remove unnecessary argv copy to plug leak 2021-07-26 12:19:20 -07:00
fsck.c run-command API users: use strvec_pushl(), not argv construction 2021-11-25 22:15:07 -08:00
fsmonitor--daemon.c fsmonitor: fix race seen in t7527 2022-12-02 09:07:48 +09:00
gc.c Merge branch 'ab/config-based-hooks-2' 2022-02-09 14:21:00 -08:00
get-tar-commit-id.c
grep.c Merge branch 'ab/grep-patterntype' 2022-02-25 15:47:36 -08:00
hash-object.c Merge branch 'ja/i18n-common-messages' 2022-02-25 15:47:35 -08:00
help.c i18n: remove from i18n strings that do not hold translatable parts 2022-02-04 13:58:28 -08:00
hook.c git hook run: add an --ignore-missing flag 2022-01-07 15:19:34 -08:00
index-pack.c i18n: factorize "--foo requires --bar" and the like 2022-01-05 13:31:00 -08:00
init-db.c i18n: refactor "foo and bar are mutually exclusive" 2022-01-05 13:29:23 -08:00
interpret-trailers.c
log.c Merge branch 'ab/grep-patterntype' 2022-02-25 15:47:36 -08:00
ls-files.c Merge branch 'ja/i18n-similar-messages' 2022-01-10 11:52:56 -08:00
ls-remote.c ls-remote & transport API: release "struct transport_ls_refs_options" 2022-02-06 18:02:34 -08:00
ls-tree.c built-ins: trust the "prefix" from run_builtin() 2022-02-15 18:00:50 -08:00
mailinfo.c
mailsplit.c use xopen() to handle fatal open(2) failures 2021-08-25 14:39:08 -07:00
merge-base.c i18n: factorize more 'incompatible options' messages 2022-02-04 13:58:28 -08:00
merge-file.c xdiff: implement a zealous diff3, or "zdiff3" 2021-12-01 14:45:58 -08:00
merge-index.c
merge-ours.c
merge-recursive.c
merge-tree.c
merge.c Merge branch 'pw/use-in-process-checkout-in-rebase' 2022-02-18 13:53:27 -08:00
mktag.c i18n: remove from i18n strings that do not hold translatable parts 2022-02-04 13:58:28 -08:00
mktree.c i18n: remove from i18n strings that do not hold translatable parts 2022-02-04 13:58:28 -08:00
multi-pack-index.c builtin/multi-pack-index.c: don't leak concatenated options 2021-10-28 15:32:14 -07:00
mv.c mv: refuse to move sparse paths 2021-09-28 10:31:02 -07:00
name-rev.c name-rev: replace --stdin with --annotate-stdin in synopsis 2022-02-15 17:37:43 -08:00
notes.c i18n: remove from i18n strings that do not hold translatable parts 2022-02-04 13:58:28 -08:00
pack-objects.c Merge branch 'ja/i18n-common-messages' 2022-02-25 15:47:35 -08:00
pack-redundant.c
pack-refs.c
patch-id.c patch-id: fix scan_hunk_header on diffs with 1 line of before/after 2022-02-02 11:24:23 -08:00
prune-packed.c i18n: remove from i18n strings that do not hold translatable parts 2022-02-04 13:58:28 -08:00
prune.c Merge branch 'ns/tmp-objdir' 2022-01-03 16:24:15 -08:00
pull.c Merge branch 'ja/i18n-common-messages' 2022-02-25 15:47:35 -08:00
push.c i18n: factorize "invalid value" messages 2022-02-04 13:58:28 -08:00
range-diff.c
read-tree.c Change unpack_trees' 'reset' flag into an enum 2021-09-27 13:38:37 -07:00
rebase.c Merge branch 'ja/i18n-common-messages' 2022-02-25 15:47:35 -08:00
receive-pack.c Merge branch 'cb/clear-quarantine-early-on-all-ref-update-errors' 2022-02-18 13:53:27 -08:00
reflog.c Merge branch 'ja/i18n-common-messages' 2022-02-25 15:47:35 -08:00
remote-ext.c
remote-fd.c
remote.c i18n: remove from i18n strings that do not hold translatable parts 2022-02-04 13:58:28 -08:00
repack.c Merge branch 'ja/i18n-similar-messages' 2022-01-10 11:52:56 -08:00
replace.c i18n: remove from i18n strings that do not hold translatable parts 2022-02-04 13:58:28 -08:00
rerere.c
reset.c Merge branch 'ab/diff-free-more' 2022-02-25 15:47:36 -08:00
rev-list.c i18n: fix some misformated placeholders in command synopsis 2022-02-04 13:58:28 -08:00
rev-parse.c refs: drop "broken" flag from for_each_fullref_in() 2021-09-27 12:36:45 -07:00
revert.c Merge branch 'ds/mergies-with-sparse-index' 2021-09-20 15:20:45 -07:00
rm.c Merge branch 'ja/i18n-similar-messages' 2022-01-10 11:52:56 -08:00
send-pack.c i18n: factorize "invalid value" messages 2022-02-04 13:58:28 -08:00
shortlog.c log: add a --no-graph option 2022-02-11 10:06:41 -08:00
show-branch.c date API: create a date.h, split from cache.h 2022-02-16 09:40:00 -08:00
show-index.c
show-ref.c
sparse-checkout.c Merge branch 'ja/i18n-common-messages' 2022-02-25 15:47:35 -08:00
stash.c Merge branch 'js/no-more-legacy-stash' 2022-02-16 15:14:30 -08:00
stripspace.c i18n: remove from i18n strings that do not hold translatable parts 2022-02-04 13:58:28 -08:00
submodule--helper.c Merge branch 'js/apply-partial-clone-filters-recursively' 2022-02-25 15:47:35 -08:00
symbolic-ref.c
tag.c date API: create a date.h, split from cache.h 2022-02-16 09:40:00 -08:00
unpack-file.c
unpack-objects.c
update-index.c fsmonitor: config settings are repository-specific 2022-03-25 16:04:15 -07:00
update-ref.c update-ref: fix streaming of status updates 2021-09-03 11:35:15 -07:00
update-server-info.c i18n: remove from i18n strings that do not hold translatable parts 2022-02-04 13:58:28 -08:00
upload-archive.c upload-archive: use regular "struct child_process" pattern 2021-11-25 22:15:07 -08:00
upload-pack.c upload-pack: document and rename --advertise-refs 2021-08-05 08:59:37 -07:00
var.c var: add GIT_DEFAULT_BRANCH variable 2021-11-03 13:25:36 -07:00
verify-commit.c
verify-pack.c
verify-tag.c
worktree.c Merge branch 'ds/sparse-checkout-requires-per-worktree-config' 2022-02-25 15:47:33 -08:00
write-tree.c