Feedback on patch [PATCH v13 3/5] fe_utils: Simplify cancel logic in wait_on_slots:

1) The value

    struct timeval tv = {0, 1000000};

is actually somewhat incorrect if you think about it.  It should be

    struct timeval tv = {1, 0};

Apparently Windows and Linux accept the former in select(), but it fails on macOS, and probably other BSD-derived systems.

Previously, this was only in the Windows code path, but now it's in the fallback code for systems without pselect().

Actually, pselect() is in POSIX, so we should be able to require it unconditionally on non-Windows system. Maybe it would be simpler and more robust if select_loop() only had a Windows and a non-Windows code path, instead of effectively three code paths as the patch is proposing (pselect, Unix-no-pselect, Windows).

2) The new code loses the message "Cancel request sent" under some circumstances. For example: Create three tables and lock them:

create table t1 (a int);
create table t2 (a int);
create table t3 (a int);

begin;
lock t1, t2, t3;
-- keep transaction open

Then in a separate terminal run a parallel vacuumdb with less slots than tables:

vacuumdb -j2

Then press Ctrl+C as it hangs.

This aborts without printing a message.

If you lock only one table (so that there are more slots than tasks) and press Ctrl+C, then the message is printed.

This should be fixed because the inconsistent behavior would inevitably confuse users.

3) Small code simplification:

The

+   if (i < 0)
+       return -1;

is unnecessary, because if i is < 0 then it is necessarily -1, as a result from pselect() or select(), and so the subsequent "return i" is enough.


I have also looked at [PATCH v13 4/5] Move Windows pthread compatibility functions to src/port. This makes a lot of sense to me, also seeing that the corresponding header file pthread-win32.h is already in src/port/.

But actually shouldn't the header file be in src/include/port/ (or maybe src/include/port/win32/)? Your 0005 patch needs to do some build system surgery to find this file in its current nonstandard place.



Reply via email to