postgresql/src/backend
Thomas Munro 1bf47d8977 Check for STATUS_DELETE_PENDING on Windows.
1.  Update our open() wrapper to check for NT's STATUS_DELETE_PENDING
and translate it to Unix-like errors.  This is done with
RtlGetLastNtStatus(), which is dynamically loaded from ntdll.  A new
file win32ntdll.c centralizes lookup of NT functions, in case we decide
to add more in the future.

2.  Remove non-working code that was trying to do something similar for
stat(), and just reuse the open() wrapper code.  As a side effect,
stat() also gains resilience against "sharing violation" errors.

3.  Since stat() is used very early in process startup, remove the
requirement that the Win32 signal event has been created before
pgwin32_open_handle() is reached.  Instead, teach pg_usleep() to fall
back to a non-interruptible sleep if reached before the signal event is
available.

This could be back-patched, but for now it's in master only.  The
problem has apparently been with us for a long time and generated only a
few complaints.  Proposed patches trigger it more often, which led to
this investigation and fix.

Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKGJz_pZTF9mckn6XgSv69%2BjGwdgLkxZ6b3NWGLBCVjqUZA%40mail.gmail.com
(cherry picked from commit e2f0f8ed25)

Author: Thomas Munro <tmunro@postgresql.org>
Author: Alexandra Wang <alexandra.wang.oss@gmail.com>
2024-11-08 09:34:00 +10:30
..
access Revert "For inplace update, send nontransactional invalidations." 2024-11-02 09:05:05 -07:00
bootstrap Rethink definition of pg_attribute.attcompression. 2021-05-27 13:24:27 -04:00
catalog Suppress new "may be used uninitialized" warning. 2024-11-02 19:42:57 -07:00
commands Restructure foreign key handling code for ATTACH/DETACH 2024-10-22 16:01:18 +02:00
executor Remove unnecessary word in a comment 2024-10-23 17:55:31 +09:00
foreign Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:23 -07:00
jit Monkey-patch LLVM code to fix ARM relocation bug. 2024-11-06 23:09:50 +13:00
lib Fix lock assertions in dshash.c. 2022-07-11 15:47:12 +12:00
libpq Fix regression in TLS session ticket disabling 2024-08-19 12:55:11 +02:00
main Fix outdated --help message for postgres -f 2022-08-15 13:37:38 +09:00
nodes Remove inappropriate raw_expression_tree_walker() code 2023-06-29 10:35:53 +02:00
optimizer Correctly identify which EC members are computable at a plan node. 2024-10-12 14:56:08 -04:00
parser Remove incorrect Assert. 2024-09-11 11:42:14 -04:00
partitioning Fix creation of partition descriptor during concurrent detach+drop 2024-08-12 18:17:56 -04:00
po Translation updates 2024-08-05 12:22:08 +02:00
port Check for STATUS_DELETE_PENDING on Windows. 2024-11-08 09:34:00 +10:30
postmaster Fix bugs in MultiXact truncation 2024-06-26 23:06:12 +03:00
regex Avoid character classification in regex escape parsing. 2023-04-21 08:20:32 -07:00
replication Revert "For inplace update, send nontransactional invalidations." 2024-11-02 09:05:05 -07:00
rewrite Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:23 -07:00
snowball In the Snowball dictionary, don't try to stem excessively-long words. 2022-08-31 10:42:05 -04:00
statistics Fix incorrectly reported stats kind in "can't happen" ERROR 2024-03-05 16:18:42 +13:00
storage At end of recovery, reset all sinval-managed caches. 2024-10-25 06:51:07 -07:00
tcop Add missing query ID reporting in extended query protocol 2024-09-18 09:59:26 +09:00
tsearch Limit to_tsvector_byid's initial array allocation to something sane. 2023-09-25 11:50:28 -04:00
utils Revert "For inplace update, send nontransactional invalidations." 2024-11-02 09:05:05 -07:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
nls.mk Translation updates 2021-09-20 16:23:13 +02:00