Skip to contentSkip to conversation

Git v2.32.0-rc3 - t5300 Still Broken on NonStop ia64/x86

ANNOUNCE Randall S. Becker 7 participants 22 messages Jun 2, 2021 – Jun 8, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw
Quoted 5 lines · Junio C Hamano

Subject: [ANNOUNCE] Git v2.32.0-rc3

A release candidate Git v2.32.0-rc3 is now available for testing at the usual places. It is comprised of 589 non-merge commits since v2.31.0, contributed by 84 people, 31 of which are new faces [*].

Here is the current -x output from t5300. That last known working version was 2.31.1.

<snip>
ok 1 - setup

expecting success of 5300.2 'pack without delta':

        packname_1=$(git pack-objects --progress --window=0 test-1 \
                        <obj-list 2>stderr) &&
        check_deltas stderr = 0

+ + git pack-objects --progress --window=0 test-1
+ 0< obj-list 2> stderr
packname_1=
error: last command exited with $?=128 not ok 2 - pack without delta
#
# packname_1=$(git pack-objects --progress --window=0 test-1 \
# <obj-list 2>stderr) &&
# check_deltas stderr = 0
#

Working area is:

-rw-rw-r-- 1 JENKINS.JENKINS JENKINS    4096 Jun  2 12:47 a
-rw-rw-r-- 1 JENKINS.JENKINS JENKINS 2097152 Jun  2 12:47 a_big
-rw-rw-r-- 1 JENKINS.JENKINS JENKINS    4096 Jun  2 12:47 b
-rw-rw-r-- 1 JENKINS.JENKINS JENKINS 2097152 Jun  2 12:47 b_big
-rw-rw-r-- 1 JENKINS.JENKINS JENKINS    4096 Jun  2 12:47 c
-rw-rw-r-- 1 JENKINS.JENKINS JENKINS    4100 Jun  2 12:47 d
-rw-rw-r-- 1 JENKINS.JENKINS JENKINS 4228179 Jun  2 12:48 expect
-rw-rw-r-- 1 JENKINS.JENKINS JENKINS     328 Jun  2 12:48 obj-list
-rw-rw-r-- 1 JENKINS.JENKINS JENKINS     605 Jun  2 12:48 stderr

Stderr contains:
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
fatal: fsync error on '.git/objects/pack/tmp_pack_NkPgqN': Interrupted system call

The maximum platform I/O size is 56Kb.

I'm happy to help figure this out but need some direction. I don't know the pack-object code.

Sincerely,
Randall

#1 lore raw
Quoted 2 lines · Randall S. Becker

I'm happy to help figure this out but need some direction. I don't know the pack-object code.

Is the failure consistent, i.e., that it occurs every time you run the test? Not knowing much about your platform, it would be helpful to have a bisection showing where this breakage first occurs.

Thanks,
Taylor

#2 lore raw
Quoted 7 lines · Taylor Blau
Quoted 2 lines · Randall S. Becker

I'm happy to help figure this out but need some direction. I don't know the pack-object code.

Is the failure consistent, i.e., that it occurs every time you run the test? Not knowing much about your platform, it would be helpful to have a bisection showing where this breakage first occurs.

I suspect the symptom comes from the test Randall noted, but that the actual issue has been there all along. The test uses "--progress" explicitly, so we'll be sending SIGALRM (whereas most tests will disable the progress mechanism because their output isn't going to a tty).

And so when he gets this error:

fatal: fsync error on '.git/objects/pack/tmp_pack_NkPgqN': Interrupted system call

presumably we were in fsync() when the signal arrived, and unlike most other platforms, the call needs to be restarted manually (even though we set up the signal with SA_RESTART). I'm not sure if this violates POSIX or not (I couldn't find a definitive answer to the set of interruptible functions in the standard). But either way, the workaround is probably something like:

#ifdef FSYNC_NEEDS_RESTART
#undef fsync /* we'd define to git_fsync() in a header file */ static int git_fsync(int fd)

  {
	int ret;
	while ((ret = fsync(fd)) < 0 && errno == EINTR)
		; /* try again */
	return ret;

}
#endif

-Peff

#3 lore raw
Quoted 7 lines · Jeff King

And so when he gets this error:

fatal: fsync error on '.git/objects/pack/tmp_pack_NkPgqN': Interrupted system call

presumably we were in fsync() when the signal arrived, and unlike most other platforms, the call needs to be restarted manually (even though we set up the signal with SA_RESTART).

Aha, thanks for explaining. That makes sense to me.

Quoted 3 lines

I'm not sure if this violates POSIX or not (I couldn't find a definitive answer to the set of interruptible functions in the standard).

I couldn't find anything either, but I believe you that what you outlined is the right solution.

Quoted 1 line

But either way, the workaround is probably something like:

Seems very reasonable. Here's a patch:

--- >8 ---

Subject: [PATCH] compat: introduce git_fsync_with_restart()

Some platforms, like NonStop do not automatically restart fsync() when interrupted by a signal, even when that signal is setup with SA_RESTART.

This can lead to test breakage, e.g., where "--progress" is used, thus SIGALRM is sent often, and can interrupt an fsync() syscall.

Add a Makefile knob FSYNC_NEEDS_RESTART to replace fsync() with one that gracefully handles getting EINTR.

---
 Makefile          |  8 ++++++++
 compat/fsync.c    | 10 ++++++++++
 git-compat-util.h |  6 ++++++
 3 files changed, 24 insertions(+)
 create mode 100644 compat/fsync.c
Makefile +8 -0
index c3565fc0f8..ebea693a2c 100644
@@ -423,6 +423,9 @@ all::
 # Define NEED_ACCESS_ROOT_HANDLER if access() under root may success for X_OK
 # even if execution permission isn't granted for any user.
 #
+# Define FSYNC_NEEDS_RESTART if your platform's fsync() needs to be restarted
+# manually when interrupted by a signal.
+#
 # Define PAGER_ENV to a SP separated VAR=VAL pairs to define
 # default environment variables to be passed when a pager is spawned, e.g.
 #
@@ -1926,6 +1929,11 @@ ifdef NEED_ACCESS_ROOT_HANDLER
 	COMPAT_OBJS += compat/access.o
 endif
 
+ifdef FSYNC_NEEDS_RESTART
+	COMPAT_CFLAGS += -DFSYNC_NEEDS_RESTART
+	COMPAT_OBJS += compat/fsync.o
+endif
+
 ifeq ($(TCLTK_PATH),)
 NO_TCLTK = NoThanks
 endif
compat/fsync.c new file +10 -0
new file mode 100644
index 0000000000..f340fc628b
@@ -0,0 +1,10 @@
+#include "git-compat-util.h"
+
+#undef fsync
+int git_fsync_with_restart(int fd)
+{
+	int ret;
+	while ((ret = fsync(fd)) < 0 && errno == EINTR)
+		; /* try again */
+	return ret;
+}
git-compat-util.h +6 -0
index a508dbe5a3..972fdb609f 100644
@@ -833,6 +833,12 @@ const char *inet_ntop(int af, const void *src, char *dst, size_t size);
 int git_atexit(void (*handler)(void));
 #endif
 
+#ifdef FSYNC_NEEDS_RESTART
+#undef fsync
+#define fsync git_fsync_with_restart
+int git_fsync_with_restart(int fd);
+#endif
+
 static inline size_t st_add(size_t a, size_t b)
 {
 	if (unsigned_add_overflows(a, b))

--
2.31.1.163.ga65ce7f831

#4 lore raw
Quoted 5 lines · Taylor Blau

Subject: [PATCH] compat: introduce git_fsync_with_restart()

Some platforms, like NonStop do not automatically restart fsync() when interrupted by a signal, even when that signal is setup with SA_RESTART.

Quoted 8 lines

This can lead to test breakage, e.g., where "--progress" is used, thus SIGALRM is sent often, and can interrupt an fsync() syscall.

Add a Makefile knob FSYNC_NEEDS_RESTART to replace fsync() with one that gracefully handles getting EINTR.

Probably Helped-by might be more appropriate. But regardless, I definitely give my S-o-B for anything I contributed.

Quoted 5 lines
 Makefile          |  8 ++++++++
 compat/fsync.c    | 10 ++++++++++
 git-compat-util.h |  6 ++++++
 3 files changed, 24 insertions(+)
 create mode 100644 compat/fsync.c

This looks as I'd expect. But after seeing Eric's response, we perhaps want to do away with the knob entirely.

-Peff

#5 lore raw
Quoted 22 lines · Peff

To: Taylor Blau <[email protected]>
Cc: Randall S. Becker <[email protected]>; 'Junio C Hamano' <[email protected]>; [email protected]
Subject: Re: [ANNOUNCE] Git v2.32.0-rc3 - t5300 Still Broken on NonStop ia64/x86

Quoted 5 lines · Taylor Blau

Subject: [PATCH] compat: introduce git_fsync_with_restart()

Some platforms, like NonStop do not automatically restart fsync() when interrupted by a signal, even when that signal is setup with SA_RESTART.

Quoted 8 lines

This can lead to test breakage, e.g., where "--progress" is used, thus SIGALRM is sent often, and can interrupt an fsync() syscall.

Add a Makefile knob FSYNC_NEEDS_RESTART to replace fsync() with one that gracefully handles getting EINTR.

Probably Helped-by might be more appropriate. But regardless, I definitely give my S-o-B for anything I contributed.

Quoted 7 lines
Quoted 5 lines
 Makefile          |  8 ++++++++
 compat/fsync.c    | 10 ++++++++++
 git-compat-util.h |  6 ++++++
 3 files changed, 24 insertions(+)
 create mode 100644 compat/fsync.c

This looks as I'd expect. But after seeing Eric's response, we perhaps want to do away with the knob entirely.

I'm for doing away with the knob altogether, providing you don't mean the platform itself 😉

Regards,
Randall

#6 lore raw
In reply to Jeff King
Quoted 2 lines · Jeff King

This looks as I'd expect. But after seeing Eric's response, we perhaps want to do away with the knob entirely.

Thanks. I was hoping somebody in the thread would tie the loose ends, but upon inspection of the output from

    $ git grep -e fsync\( maint seen -- \*.[ch]

it turns out that fsync_or_die() is the only place that calls fsync(), so perhaps doing it in a way that is quite different from what has been discussed may be even a better alternative.

If any new callers care about the return value of fsync(), I'd expect that they would be calling this wrapper, and the "best effort" callers that do not check the returned value by definition do not care if fsync() does not complete due to an interrupt, so I am hoping that the current "we only call it from this wrapper" is not just "the code currently happens to be this way", but it is sensible that the code will stay that way in the future.

Obviously I appreciate reviews and possibly tests, but sanity checking my observation that fsync() is called only from here is a good thing to have.

-- >8 --
Subject: fsync(): be prepared to see EINTR

Some platforms, like NonStop do not automatically restart fsync() when interrupted by a signal, even when that signal is setup with SA_RESTART.

This can lead to test breakage, e.g., where "--progress" is used, thus SIGALRM is sent often, and can interrupt an fsync() syscall.

Make sure we deal with such a case by retrying the syscall ourselves. Luckily, we call fsync() fron a single wrapper, fsync_or_die(), so the fix is fairly isolated.

[jc: the above two did most of the work---I just tied the loose end]

---

 write-or-die.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
write-or-die.c +5 -1
index eab8c8d0b9..534b2f5cba 100644
@@ -57,7 +57,11 @@ void fprintf_or_die(FILE *f, const char *fmt, ...)
 
 void fsync_or_die(int fd, const char *msg)
 {
-	if (fsync(fd) < 0) {
+	int status;
+
+	while ((status = fsync(fd)) < 0 && errno == EINTR)
+		; /* try again */
+	if (status < 0) {
 		die_errno("fsync error on '%s'", msg);
 	}
 }
Reviewed-by
#7 lore raw
Quoted 14 lines · Junio C Hamano
Quoted 2 lines · Jeff King

This looks as I'd expect. But after seeing Eric's response, we perhaps want to do away with the knob entirely.

Thanks. I was hoping somebody in the thread would tie the loose ends, but upon inspection of the output from

    $ git grep -e fsync\( maint seen -- \*.[ch]

it turns out that fsync_or_die() is the only place that calls fsync(), so perhaps doing it in a way that is quite different from what has been discussed may be even a better alternative.

Quoted 7 lines

If any new callers care about the return value of fsync(), I'd expect that they would be calling this wrapper, and the "best effort" callers that do not check the returned value by definition do not care if fsync() does not complete due to an interrupt, so I am hoping that the current "we only call it from this wrapper" is not just "the code currently happens to be this way", but it is sensible that the code will stay that way in the future.

That makes total sense to me; I can't imagine a scenario where you would want to call fsync() over fsync_or_die(). But if you did, then you probably don't care about whether or not fsync() was interrupted, or can check the return value yourself.

If it became more common, then I wouldn't mind #undef-ing fsync() and replacing it with our own hacked up version.

Quoted 3 lines

Obviously I appreciate reviews and possibly tests, but sanity checking my observation that fsync() is called only from here is a good thing to have.

Your patch looks good to me (and Randall already tested my version with the additional knob on NonStop and reported it working as expected[1]), so this has my:

Thanks,
Taylor

[1]: https://lore.kernel.org/git/[email protected]/

#8 lore raw
In reply to Junio C Hamano
Quoted 17 lines · Junio C Hamano

Thanks. I was hoping somebody in the thread would tie the loose ends, but upon inspection of the output from

    $ git grep -e fsync\( maint seen -- \*.[ch]

it turns out that fsync_or_die() is the only place that calls fsync(), so perhaps doing it in a way that is quite different from what has been discussed may be even a better alternative.

If any new callers care about the return value of fsync(), I'd expect that they would be calling this wrapper, and the "best effort" callers that do not check the returned value by definition do not care if fsync() does not complete due to an interrupt, so I am hoping that the current "we only call it from this wrapper" is not just "the code currently happens to be this way", but it is sensible that the code will stay that way in the future.

Quoted 3 lines

Obviously I appreciate reviews and possibly tests, but sanity checking my observation that fsync() is called only from here is a good thing to have.

Thanks for digging further. I didn't even think to look at how many calls there were, but I agree there is only the one. And moreover, I agree that it is unlikely we'd ever have more than one, for the reasons you listed. So I think your patch is a nice and simple solution, and we don't need worry about magic macro wrappers at all.

One brief aside: I'm still not entirely convinced that NonStop isn't violating POSIX. Yes, as Eric noted, fsync() is allowed to return EINTR. But should it do so when the signal it got was set up with SA_RESTART?

The sigaction(3posix) page says:

SA_RESTART This flag affects the behavior of interruptible functions;
that is, those specified to fail with errno set to [EINTR]. If set, and a function specified as interruptible is interrupted by this signal, the function shall restart and shall not fail with [EINTR] unless otherwise specified. [...]

and I could not find anywhere that it is "otherwise specified" for fsync(). Of course, whatever POSIX says, if NonStop needs this workaround, we should provide it. But this may explain why we never saw it on other systems.

It also means it's less important for this workaround to kick in everywhere. But given how low-cost it is, I'm just as happy to avoid having a separate knob to enable it.

Quoted 2 lines

-- >8 --
Subject: fsync(): be prepared to see EINTR

The patch itself looks good to me.

-Peff

#9 lore raw
Quoted 13 lines · Jeff King

One brief aside: I'm still not entirely convinced that NonStop isn't violating POSIX. Yes, as Eric noted, fsync() is allowed to return EINTR. But should it do so when the signal it got was set up with SA_RESTART?

The sigaction(3posix) page says:

SA_RESTART This flag affects the behavior of interruptible functions;
that is, those specified to fail with errno set to [EINTR]. If set, and a function specified as interruptible is interrupted by this signal, the function shall restart and shall not fail with [EINTR] unless otherwise specified. [...]

Quoted 4 lines

and I could not find anywhere that it is "otherwise specified" for fsync(). Of course, whatever POSIX says, if NonStop needs this workaround, we should provide it. But this may explain why we never saw it on other systems.

Yeah, I think all of the above makes sense.

Quoted 3 lines

It also means it's less important for this workaround to kick in everywhere. But given how low-cost it is, I'm just as happy to avoid having a separate knob to enable it.

Yes, any caller who cares about the result of fsync() is willing to wait, and on a well benaved system, we would never see EINTR so the loop won't iterate. Having to carry just a handful of extra bytes in ICache in a codepath that is not performance critical is probably an acceptable cost for simpler code.

#10 lore raw
Quoted 24 lines · Junio C Hamano

To: Jeff King <[email protected]>
Cc: Taylor Blau <[email protected]>; Randall S. Becker <[email protected]>; [email protected]
Subject: Re: [ANNOUNCE] Git v2.32.0-rc3 - t5300 Still Broken on NonStop ia64/x86

Quoted 13 lines · Jeff King

One brief aside: I'm still not entirely convinced that NonStop isn't violating POSIX. Yes, as Eric noted, fsync() is allowed to return EINTR. But should it do so when the signal it got was set up with SA_RESTART?

The sigaction(3posix) page says:

SA_RESTART This flag affects the behavior of interruptible functions;
that is, those specified to fail with errno set to [EINTR]. If set, and a function specified as interruptible is interrupted by this signal, the function shall restart and shall not fail with [EINTR] unless otherwise specified. [...]

Quoted 4 lines

and I could not find anywhere that it is "otherwise specified" for fsync(). Of course, whatever POSIX says, if NonStop needs this workaround, we should provide it. But this may explain why we never saw it on other systems.

Quoted 7 lines

Yeah, I think all of the above makes sense.

Quoted 3 lines

It also means it's less important for this workaround to kick in everywhere. But given how low-cost it is, I'm just as happy to avoid having a separate knob to enable it.

Yes, any caller who cares about the result of fsync() is willing to wait, and on a well benaved system, we would never see EINTR so

the

Quoted 1 line

loop won't iterate. Having to carry just a handful of extra bytes in ICache in a codepath that is not performance critical is

probably an

Quoted 1 line

acceptable cost for simpler code.

Just something to note: I was running git gc --aggressive on OpenSSL today and got the same error as in this case. I'm assuming that the fix will apply to that too. In this situation, the gc ran for over 2 hours until failing. This may be a more widely available test condition for fsync() EINTR, possibly.

-Randall

#11 lore raw
Quoted 5 lines · Randall S. Becker

Just something to note: I was running git gc --aggressive on OpenSSL today and got the same error as in this case. I'm assuming that the fix will apply to that too. In this situation, the gc ran for over 2 hours until failing. This may be a more widely available test condition for fsync() EINTR, possibly.

Thanks. One of my original questions was that we'd expect to see this in the wild, and not just the test suite. But it sounds like now we have. :) So I feel better that we have a full understanding of the issue.

-Peff

#12 lore raw
In reply to Junio C Hamano

Am 04.06.21 um 03:36 schrieb Junio C Hamano:

Quoted 12 lines

---

 write-or-die.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
write-or-die.c +0 -0
index eab8c8d0b9..534b2f5cba 100644
@@ -57,7 +57,11 @@ void fprintf_or_die(FILE *f, const char *fmt, ...)
 
 void fsync_or_die(int fd, const char *msg)

write-or-die.c void fprintf_or_die(FILE *f, const char *fmt, ...) · line 67

Quoted 10 lines
write-or-die.c +5 -1
 {
-	if (fsync(fd) < 0) {
+	int status;
+
+	while ((status = fsync(fd)) < 0 && errno == EINTR)
+		; /* try again */
+	if (status < 0) {
 		die_errno("fsync error on '%s'", msg);
 	}
 }

The function body can be written like this:

	while (fsync(fd) < 0) {
		if (errno != EINTR)
			die_errno("fsync error on '%s'", msg);
	}

I find it easier to read because it has less syntax elements and is shorter. Bikeshedding, of course. :-/

René

#13 lore raw
Quoted 9 lines · René Scharfe

The function body can be written like this:

	while (fsync(fd) < 0) {
		if (errno != EINTR)
			die_errno("fsync error on '%s'", msg);
	}

I find it easier to read because it has less syntax elements and is shorter. Bikeshedding, of course. :-/

It indeed is easier to follow. Thanks.

#14 lore raw
In reply to Jeff King
Quoted 10 lines · Jeff King

And so when he gets this error:

fatal: fsync error on '.git/objects/pack/tmp_pack_NkPgqN': Interrupted system call

presumably we were in fsync() when the signal arrived, and unlike most other platforms, the call needs to be restarted manually (even though we set up the signal with SA_RESTART). I'm not sure if this violates POSIX or not (I couldn't find a definitive answer to the set of interruptible functions in the standard). But either way, the workaround is probably something like:

"man 3posix fsync" says EINTR is allowed ("manpages-posix-dev" package in Debian non-free).

Quoted 1 line
  #ifdef FSYNC_NEEDS_RESTART

The wrapper should apply to all platforms. NFS (and presumably other network FSes) can be mounted with interrupts enabled.

Quoted 8 lines

#undef fsync /* we'd define to git_fsync() in a header file */ static int git_fsync(int fd)

  {
	int ret;
	while ((ret = fsync(fd)) < 0 && errno == EINTR)
		; /* try again */
	return ret;

}

Looks fine.

#15 lore raw
Quoted 12 lines · Eric Wong
Quoted 10 lines · Jeff King

And so when he gets this error:

fatal: fsync error on '.git/objects/pack/tmp_pack_NkPgqN': Interrupted system call

presumably we were in fsync() when the signal arrived, and unlike most other platforms, the call needs to be restarted manually (even though we set up the signal with SA_RESTART). I'm not sure if this violates POSIX or not (I couldn't find a definitive answer to the set of interruptible functions in the standard). But either way, the workaround is probably something like:

Quoted 2 lines

"man 3posix fsync" says EINTR is allowed ("manpages-posix-dev" package in Debian non-free).

Ah, thanks. Linux's fsync(3) doesn't mention it, and nor does it appear in the discussion of interruptible calls in signals(7). So I was looking for a POSIX equivalent of that signals manpage but couldn't find one. :)

Quoted 4 lines
Quoted 1 line
  #ifdef FSYNC_NEEDS_RESTART

The wrapper should apply to all platforms. NFS (and presumably other network FSes) can be mounted with interrupts enabled.

I don't mind that, as the wrapper is pretty low-cost (and one less Makefile knob is nice). If it's widespread, though, I find it curious that nobody has run into it before now.

-Peff

#16 lore raw
Quoted 6 lines · Jeff King
Quoted 2 lines

The wrapper should apply to all platforms. NFS (and presumably other network FSes) can be mounted with interrupts enabled.

I don't mind that, as the wrapper is pretty low-cost (and one less Makefile knob is nice). If it's widespread, though, I find it curious that nobody has run into it before now.

Yeah, I find it curious as well. I agree that the wrapper is relatively cheap (especially relative to fsync), but it seems unnecessary despite what's in POSIX's fsync(3). So the more conservative choice to me would be to hide it behind a Makefile knob, but I don't mind much either way.

Thanks,
Taylor

#17 lore raw
In reply to Jeff King
Quoted 22 lines · Peff

Subject: Re: [ANNOUNCE] Git v2.32.0-rc3 - t5300 Still Broken on NonStop ia64/x86

Quoted 13 lines · Eric Wong
Quoted 11 lines · Jeff King

And so when he gets this error:

fatal: fsync error on '.git/objects/pack/tmp_pack_NkPgqN':
Interrupted system call

presumably we were in fsync() when the signal arrived, and unlike most other platforms, the call needs to be restarted manually (even though we set up the signal with SA_RESTART). I'm not sure if this violates POSIX or not (I couldn't find a definitive answer to the set of interruptible functions in the standard). But either way, the workaround is probably something like:

Quoted 2 lines

"man 3posix fsync" says EINTR is allowed ("manpages-posix-dev" package in Debian non-free).

Ah, thanks. Linux's fsync(3) doesn't mention it, and nor does it appear in the discussion of interruptible calls in signals(7). So I was looking for a POSIX equivalent of that signals manpage but couldn't find one. :)

Quoted 7 lines
Quoted 4 lines
Quoted 1 line
  #ifdef FSYNC_NEEDS_RESTART

The wrapper should apply to all platforms. NFS (and presumably other network FSes) can be mounted with interrupts enabled.

I don't mind that, as the wrapper is pretty low-cost (and one less Makefile knob is nice). If it's widespread, though, I find it curious that nobody has run into it before now.

I suspect this is because of the way the file system on NonStop behaves. It is a multi-processor platform, with multi-cores, so anything can happen. If the file system is delayed for any reason, like a signal coming from a different core (EINTR has high priority), then fsync() will be interrupted. EINTR is allowed on NonStop for fsync(). So it would be really great if the patch included a modification to config.mak.uname to include that. This would be a timing-only issue on most other systems, probably something that would hit NFS.

The patch for the config is:

config.mak.uname +1 -0
index cb443b4e02..ac3e3ca2c5 100644
@@ -566,6 +566,7 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
        NO_REGEX = NeedsStartEnd
        NO_PTHREADS = UnfortunatelyYes
        FREAD_READS_DIRECTORIES = UnfortunatelyYes
+       FSYNC_NEEDS_RESTART = YesPlease
 
        # Not detected (nor checked for) by './configure'.
 
#18 lore raw
Quoted 14 lines · Randall S. Becker
Quoted 5 lines
Quoted 2 lines

The wrapper should apply to all platforms. NFS (and presumably other network FSes) can be mounted with interrupts enabled.

I don't mind that, as the wrapper is pretty low-cost (and one less Makefile knob is nice). If it's widespread, though, I find it curious that nobody has run into it before now.

I suspect this is because of the way the file system on NonStop behaves. It is a multi-processor platform, with multi-cores, so anything can happen. If the file system is delayed for any reason, like a signal coming from a different core (EINTR has high priority), then fsync() will be interrupted. EINTR is allowed on NonStop for fsync(). So it would be really great if the patch included a modification to config.mak.uname to include that. This would be a timing-only issue on most other systems, probably something that would hit NFS.

The patch for the config is:

config.mak.uname +0 -0
index cb443b4e02..ac3e3ca2c5 100644

config.mak.uname ifeq ($(uname_S),NONSTOP_KERNEL) · line 571

Quoted 6 lines
config.mak.uname +1 -0
@@ -566,6 +566,7 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
        NO_REGEX = NeedsStartEnd
        NO_PTHREADS = UnfortunatelyYes
        FREAD_READS_DIRECTORIES = UnfortunatelyYes
+       FSYNC_NEEDS_RESTART = YesPlease
 
        # Not detected (nor checked for) by './configure'.

Yeah, if we don't make it unconditional, then this is the obvious next step. But the more important question is: did you test this out and did it fix the test breakage you saw on NonStop?

-Peff

#19 lore raw
Quoted 24 lines · Peff
Quoted 7 lines · Randall S. Becker
Quoted 5 lines
Quoted 2 lines

The wrapper should apply to all platforms. NFS (and presumably other network FSes) can be mounted with interrupts enabled.

I don't mind that, as the wrapper is pretty low-cost (and one less
Makefile knob is nice). If it's widespread, though, I find it curious that nobody has run into it before now.

I suspect this is because of the way the file system on NonStop behaves. It is a multi-processor platform, with multi-cores, so anything

can happen. If the file system is delayed for any reason, like a signal coming from a different core (EINTR has high priority), then fsync() will be interrupted. EINTR is allowed on NonStop for fsync(). So it would be really great if the patch included a modification to config.mak.uname to include that. This would be a timing-only issue on most other systems, probably something that would hit NFS.

Quoted 12 lines

The patch for the config is:

config.mak.uname index renamed from config.mak.uname +0 -0

cb443b4e02..ac3e3ca2c5 100644

config.mak.uname +1 -0
@@ -566,6 +566,7 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
        NO_REGEX = NeedsStartEnd
        NO_PTHREADS = UnfortunatelyYes
        FREAD_READS_DIRECTORIES = UnfortunatelyYes
+       FSYNC_NEEDS_RESTART = YesPlease
 
Quoted 4 lines

config.mak.uname ifeq ($(uname_S),NONSTOP_KERNEL) · line 571

Quoted 1 line
config.mak.uname +0 -0
        # Not detected (nor checked for) by './configure'.

Yeah, if we don't make it unconditional, then this is the obvious next step. But the more important question is: did you test this out and did it fix the test breakage you saw on NonStop?

The fix works for me and t5300 passes. I tested it without the conditional approach. While the test was running, I noticed this:

+ mkdir -p /home/git/git/t/trash directory.t5300-pack-object/prereq-test-dir-FAIL_PREREQS
+ cd /home/git/git/t/trash directory.t5300-pack-object/prereq-test-dir-FAIL_PREREQS
+ test_bool_env GIT_TEST_FAIL_PREREQS false
error: last command exited with $?=1
prerequisite FAIL_PREREQS not satisfied
expecting success of 5300.32 'index-pack --threads=N or pack.threads=N warns when no pthreads':

This may be intended, but the error line showed in red.

Regards,
Randall

#20 lore raw
In reply to Jeff King
Quoted 22 lines · Jeff King
Quoted 12 lines · Eric Wong
Quoted 10 lines · Jeff King

And so when he gets this error:

fatal: fsync error on '.git/objects/pack/tmp_pack_NkPgqN': Interrupted system call

presumably we were in fsync() when the signal arrived, and unlike most other platforms, the call needs to be restarted manually (even though we set up the signal with SA_RESTART). I'm not sure if this violates POSIX or not (I couldn't find a definitive answer to the set of interruptible functions in the standard). But either way, the workaround is probably something like:

Quoted 2 lines

"man 3posix fsync" says EINTR is allowed ("manpages-posix-dev" package in Debian non-free).

Ah, thanks. Linux's fsync(3) doesn't mention it, and nor does it appear in the discussion of interruptible calls in signals(7). So I was looking for a POSIX equivalent of that signals manpage but couldn't find one. :)

Quoted 8 lines
Quoted 4 lines
Quoted 1 line
  #ifdef FSYNC_NEEDS_RESTART

The wrapper should apply to all platforms. NFS (and presumably other network FSes) can be mounted with interrupts enabled.

I don't mind that, as the wrapper is pretty low-cost (and one less Makefile knob is nice). If it's widespread, though, I find it curious that nobody has run into it before now.

I was dealing with a similar issue[1] recently, albeit not in the Git codebase but rather with Java. My issue was with epoll_wait, rather than fsync, which is documented on signal(7) as not restartable even with SA_RESTART. That led me to this[2] little bit of code inside the JVM:
#define RESTARTABLE(_cmd, _result) do { \

  do { \
    _result = _cmd; \

} while((_result == -1) && (errno == EINTR)); \
} while(0)

which they use like this[3]:
RESTARTABLE(epoll_wait(epfd, events, numfds, -1), res);

Not sure what the Git maintainers' view on macros is, but if there wasn't going to be a Makefile knob perhaps something similar might make sense as a reusable construct. Of course, it's unclear how often Git might _need_ such a thing; given this doesn't seem to come up much, perhaps that's a sign such a macro would end up a waste of effort. Anyway, just thought I'd share because I was looking at something similar.

[1] https://github.com/brettwooldridge/NuProcess/issues/124
[2] https://github.com/JetBrains/jdk8u_jdk/blob/94318f9185757cc33d2b8d527d36be26ac6b7582/src/solaris/native/sun/nio/ch/nio_util.h#L33-L37
[3] https://github.com/JetBrains/jdk8u_jdk/blob/94318f9185757cc33d2b8d527d36be26ac6b7582/src/solaris/native/sun/nio/ch/EPoll.c#L92

Quoted 2 lines

-Peff

#21 lore raw
Quoted 50 lines · Bryan Turner
Quoted 24 lines · Jeff King
Quoted 13 lines · Eric Wong
Quoted 11 lines · Jeff King

And so when he gets this error:

fatal: fsync error on '.git/objects/pack/tmp_pack_NkPgqN':
Interrupted system call

presumably we were in fsync() when the signal arrived, and unlike most other platforms, the call needs to be restarted manually (even though we set up the signal with SA_RESTART). I'm not sure if this violates POSIX or not (I couldn't find a definitive answer to the set of interruptible functions in the standard). But either way, the workaround is probably something like:

Quoted 2 lines

"man 3posix fsync" says EINTR is allowed ("manpages-posix-dev" package in Debian non-free).

Ah, thanks. Linux's fsync(3) doesn't mention it, and nor does it appear in the discussion of interruptible calls in signals(7). So I was looking for a POSIX equivalent of that signals manpage but couldn't find one. :)

Quoted 8 lines
Quoted 4 lines
Quoted 1 line
  #ifdef FSYNC_NEEDS_RESTART

The wrapper should apply to all platforms. NFS (and presumably other network FSes) can be mounted with interrupts enabled.

I don't mind that, as the wrapper is pretty low-cost (and one less Makefile knob is nice). If it's widespread, though, I find it curious that nobody has run into it before now.

I was dealing with a similar issue[1] recently, albeit not in the Git codebase but rather with Java. My issue was with epoll_wait, rather than fsync, which is documented on signal(7) as not restartable even with SA_RESTART. That led me to this[2] little bit of code inside the JVM:
#define RESTARTABLE(_cmd, _result) do { \

 do { \
   _result = _cmd; \

} while((_result == -1) && (errno == EINTR)); \ } while(0)

which they use like this[3]:
RESTARTABLE(epoll_wait(epfd, events, numfds, -1), res);

Not sure what the Git maintainers' view on macros is, but if there wasn't going to be a Makefile knob perhaps something similar might make sense as a reusable construct. Of course, it's unclear how often Git might _need_ such a thing; given this doesn't seem to come up much, perhaps that's a sign such a macro would end up a waste of effort. Anyway, just thought I'd share because I was looking at something similar.

Quoted 6 lines

[1] https://github.com/brettwooldridge/NuProcess/issues/124
[2]
https://github.com/JetBrains/jdk8u_jdk/blob/94318f9185757cc33d2b8d527d36be26ac6b7582/src/solaris/native/sun/nio/ch/nio_util.h#L33
-L37
[3]
https://github.com/JetBrains/jdk8u_jdk/blob/94318f9185757cc33d2b8d527d36be26ac6b7582/src/solaris/native/sun/nio/ch/EPoll.c#L92

I can only suggest, from other OpenSource projects I'm on, that make extensive use of macros, that they are very difficult to debug and sometimes harder to integrate with platform-specific compatibility layers. I would rather have something explicit in compat.c that gdb could make sense of during a debug session if necessary. Trying to debug macros is harsh, rather like debugging -O2 without -g.

I used to be a big fan of macros, but grew out of it 😉. Just my take on it.

-Randall