{"thread":{"id":"57322","subject":"spurious git stash create failures","startedAt":"2022-01-27T15:09:27Z","lastAt":"2022-01-28T09:19:32Z","messageCount":2,"participants":["clime"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"447084","messageId":"CAGqZTUuLNoZR7L9r1unR75S4Gte83DGSV2QUnGG2PqQOPBigAg@mail.gmail.com","threadId":"57322","inReplyTo":null,"subject":"spurious git stash create failures","fromName":"clime","fromEmail":"clime7@gmail.com","sentAt":"2022-01-27T15:09:10Z","receivedAt":"2022-01-27T15:09:27Z","isPatch":false,"sender":{"key":"clime7@gmail.com","avatar":"https://gravatar.com/avatar/d99ae46a5b0f57415bb74fc6c8ecd7eec304ff769f298c3be00fabf961b215ff?d=mp&s=160"},"body":"Hello,\n\nI am using `git stash create` from a python script and occasionally it\nfails with return code 1 without seemingly any reason (i.e. without\nprinting anything to stderr).\n\nAfter discussing this in the git irc channel, I have added strace to\nthe call (GIT_TRACE=2 env var didn't provide any info except: \"trace:\nbuilt-in: git stash create\" and then fail).\n\nI also wrapped the call in for loop to retry if it fails ;( and today,\non a clean work-tree, it failed once and then immediately succeeded on\nnext loop iteration a few tens of ms later. Here are strace parts that\nwent differently in each try:\n\n(I reproduced this on git 2.30 and 2.31 on two different systems, i\ndon't use any GUI or IDE, just the script that calls git stash\ncreate).\n\n...\nnewfstatat(AT_FDCWD, \"merge_runs.py\", {st_mode=S_IFREG|0775,\nst_size=1164, ...}, AT_SYMLINK_NOFOLLOW) = 0\nnewfstatat(AT_FDCWD, \"paper_reproducer\", {st_mode=S_IFREG|0775,\nst_size=81651, ...}, AT_SYMLINK_NOFOLLOW) = 0   ### till now the same\nin successful run\nreadlink(\".git/index\", 0x55c61b001a30, 32) = -1 EINVAL (Invalid\nargument)   ### this block until ENDBLOCK is only present in the\nfailed run\ngetcwd(\"/home/clime/vizorbot\", 129) = 21\nopenat(AT_FDCWD, \"/home/clime/vizorbot/.git/index.lock\",\nO_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0666) = 3\nrt_sigaction(SIGINT, {sa_handler=0x55c6198df5a0, sa_mask=[INT],\nsa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f9d3d534320},\n{sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0\nrt_sigaction(SIGHUP, {sa_handler=0x55c6198df5a0, sa_mask=[HUP],\nsa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f9d3d534320},\n{sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0\nrt_sigaction(SIGTERM, {sa_handler=0x55c6198df5a0, sa_mask=[TERM],\nsa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f9d3d534320},\n{sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0\nrt_sigaction(SIGQUIT, {sa_handler=0x55c6198df5a0, sa_mask=[QUIT],\nsa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f9d3d534320},\n{sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0\nrt_sigaction(SIGPIPE, {sa_handler=0x55c6198df5a0, sa_mask=[PIPE],\nsa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f9d3d534320},\n{sa_handler=SIG_DFL, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART,\nsa_restorer=0x7f9d3d534320}, 8) = 0\ngetpid() = 7126\nnewfstatat(AT_FDCWD, \"paper_reproducer\", {st_mode=S_IFREG|0775,\nst_size=81651, ...}, AT_SYMLINK_NOFOLLOW) = 0\nopenat(AT_FDCWD, \"paper_reproducer\", O_RDONLY|O_CLOEXEC) = 4\nopenat(AT_FDCWD, \"/etc/gitattributes\", O_RDONLY) = -1 ENOENT (No such\nfile or directory)\nopenat(AT_FDCWD, \"/home/clime/.config/git/attributes\", O_RDONLY) = -1\nENOENT (No such file or directory)\nopenat(AT_FDCWD, \".gitattributes\", O_RDONLY) = -1 ENOENT (No such file\nor directory)\nopenat(AT_FDCWD, \".git/info/attributes\", O_RDONLY) = -1 ENOENT (No\nsuch file or directory)\nmmap(NULL, 81651, PROT_READ, MAP_PRIVATE, 4, 0) = 0x7f9d2fe30000\nmunmap(0x7f9d2fe30000, 81651) = 0\nclose(4) = 0\nnewfstatat(AT_FDCWD, \"param_sets\", {st_mode=S_IFDIR|0775,\nst_size=4096, ...}, AT_SYMLINK_NOFOLLOW) = 0   ### ENDBLOCK\nnewfstatat(AT_FDCWD, \"param_sets/params0\", {st_mode=S_IFDIR|0775,\nst_size=4096, ...}, AT_SYMLINK_NOFOLLOW) = 0\n\n... now this part in the end is also only in failed run:\n\nlseek(3, 0, SEEK_CUR) = 0\nlseek(3, 0, SEEK_CUR) = 0\nwrite(3, \"DIRC\\0\\0\\0\\2\\0\\0\\0016a\\354'@%\\253\\301\\36a\\354'@%\\253\\301\\36\\0\\0\\375\\0\"...,\n48938) = 48938\nclose(3) = 0\nnewfstatat(AT_FDCWD, \"/home/clime/vizorbot/.git/index.lock\",\n{st_mode=S_IFREG|0664, st_size=48938, ...}, 0) = 0\nrename(\"/home/clime/vizorbot/.git/index.lock\",\n\"/home/clime/vizorbot/.git/index\") = 0\naccess(\".git/hooks/post-index-change\", X_OK) = -1 ENOENT (No such file\nor directory)\nnewfstatat(AT_FDCWD, \".git/HEAD\", {st_mode=S_IFREG|0664, st_size=23,\n...}, AT_SYMLINK_NOFOLLOW) = 0\nopenat(AT_FDCWD, \".git/HEAD\", O_RDONLY) = 3\nread(3, \"ref: refs/heads/master\\n\", 256) = 23\nread(3, \"\", 233) = 0\nclose(3) = 0\nnewfstatat(AT_FDCWD, \".git/refs/heads/master\", {st_mode=S_IFREG|0664,\nst_size=41, ...}, AT_SYMLINK_NOFOLLOW) = 0\nopenat(AT_FDCWD, \".git/refs/heads/master\", O_RDONLY) = 3\nread(3, \"71bbd69706edf1746ce971e495f841a5\"..., 256) = 41\nread(3, \"\", 215) = 0\nclose(3) = 0\nnewfstatat(AT_FDCWD, \".git/refs/HEAD\", 0x7ffc90cf1990,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/refs/tags/HEAD\", 0x7ffc90cf1990,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/refs/heads/HEAD\", 0x7ffc90cf1990,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/refs/remotes/HEAD\", 0x7ffc90cf1990,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/refs/remotes/HEAD/HEAD\", 0x7ffc90cf1990,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/HEAD\", {st_mode=S_IFREG|0664, st_size=23,\n...}, AT_SYMLINK_NOFOLLOW) = 0\nopenat(AT_FDCWD, \".git/HEAD\", O_RDONLY) = 3\nread(3, \"ref: refs/heads/master\\n\", 256) = 23\nread(3, \"\", 233) = 0\nclose(3) = 0\nnewfstatat(AT_FDCWD, \".git/refs/heads/master\", {st_mode=S_IFREG|0664,\nst_size=41, ...}, AT_SYMLINK_NOFOLLOW) = 0\nopenat(AT_FDCWD, \".git/refs/heads/master\", O_RDONLY) = 3\nread(3, \"71bbd69706edf1746ce971e495f841a5\"..., 256) = 41\nread(3, \"\", 215) = 0\nclose(3) = 0\nnewfstatat(AT_FDCWD, \".git/refs/HEAD\", 0x7ffc90cf1990,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/refs/tags/HEAD\", 0x7ffc90cf1990,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/refs/heads/HEAD\", 0x7ffc90cf1990,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/refs/remotes/HEAD\", 0x7ffc90cf1990,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/refs/remotes/HEAD/HEAD\", 0x7ffc90cf1990,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/HEAD\", {st_mode=S_IFREG|0664, st_size=23,\n...}, AT_SYMLINK_NOFOLLOW) = 0\nopenat(AT_FDCWD, \".git/HEAD\", O_RDONLY) = 3\nread(3, \"ref: refs/heads/master\\n\", 256) = 23\nread(3, \"\", 233) = 0\nclose(3) = 0\nnewfstatat(AT_FDCWD, \".git/refs/heads/master\", {st_mode=S_IFREG|0664,\nst_size=41, ...}, AT_SYMLINK_NOFOLLOW) = 0\nopenat(AT_FDCWD, \".git/refs/heads/master\", O_RDONLY) = 3\nread(3, \"71bbd69706edf1746ce971e495f841a5\"..., 256) = 41\nread(3, \"\", 215) = 0\nclose(3) = 0\nnewfstatat(AT_FDCWD, \".git/refs/HEAD\", 0x7ffc90cf0db0,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/refs/tags/HEAD\", 0x7ffc90cf0db0,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/refs/heads/HEAD\", 0x7ffc90cf0db0,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/refs/remotes/HEAD\", 0x7ffc90cf0db0,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\nnewfstatat(AT_FDCWD, \".git/refs/remotes/HEAD/HEAD\", 0x7ffc90cf0db0,\nAT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)\nnewfstatat(AT_FDCWD, \".git/packed-refs\", {st_mode=S_IFREG|0664,\nst_size=373, ...}, 0) = 0\ngetpid() = 7126\nexit_group(1) = ?\n+++ exited with 1 +++\n\nBest regards\nclime\n"},{"id":"447178","messageId":"CAGqZTUue90yqwK5w8RsH3iG7uMYCXb1kFWZhKOMXXkN=Wjc+oQ@mail.gmail.com","threadId":"57322","inReplyTo":"CAGqZTUuLNoZR7L9r1unR75S4Gte83DGSV2QUnGG2PqQOPBigAg@mail.gmail.com","subject":"Re: spurious git stash create failures","fromName":"clime","fromEmail":"clime7@gmail.com","sentAt":"2022-01-28T09:19:15Z","receivedAt":"2022-01-28T09:19:32Z","isPatch":false,"sender":{"key":"clime7@gmail.com","avatar":"https://gravatar.com/avatar/d99ae46a5b0f57415bb74fc6c8ecd7eec304ff769f298c3be00fabf961b215ff?d=mp&s=160"},"body":"Can it be that `git stash create` operation uses threads in some\nfashion and there is a race condition?\n\nThank you\nclime\n"}]}