Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wI6g8-007nP9-1o for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Apr 2026 15:18:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wI6g6-003u4q-2N for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Apr 2026 15:18:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wI6g6-003u4h-1D for pgsql-hackers@lists.postgresql.org; Wed, 29 Apr 2026 15:18:18 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wI6g4-00000003MXc-0ykI for pgsql-hackers@lists.postgresql.org; Wed, 29 Apr 2026 15:18:17 +0000 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-82f1fbe6899so502197b3a.0 for ; Wed, 29 Apr 2026 08:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777475895; x=1778080695; darn=lists.postgresql.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dMsAfWb8VPl/VrMxX6HwALMH8NkYQe2xY7JAS9wSnOY=; b=HPqSFHtzzsXK0rucqlOPGFJkDLEG/jcxtZJT3HlaizOEldDXNH1eNdLejqjHxJ+FnL 6lSilzLwTtj0asGF0b9v2ct4O6YQ+gT4ni4pyZyb08JCuPTmUnX03aJ0etGqt1MoCESy zHfzNbrgEmCFGDUCvBL2k2YFWl7ew0tC8T8pwAygXnVkkowddoPBwGUsoFtO3WD/EpCL r8etL/X5/zRUJyxSeb8U6981PispiI/OA0ERUpXDXs11Hq8tlXR2VBlw5H+LgGcz7YoE qa1/PGaYnyVFlJj8QGFw3AV8Qci8Q7c1mZuo5LN3ZNciCPfLVncfdbTw8LoSbIbtw/cy Y5VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777475895; x=1778080695; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dMsAfWb8VPl/VrMxX6HwALMH8NkYQe2xY7JAS9wSnOY=; b=r+HJfbHhb0ojKnRnhCTNZ8tBwYtADQrZboucWG03hVIo6pP8dZor51Md6M+q2uGqYL q4UhIlWs7FH97yBaU37rwQG2GL9BLEKAKeW2dT3YmP5/FDUyXp3n+VVCYUpaK34TIKPa BIPtRqznOgSa/FS8q1LiIFEZ3n0NDlFcefNpvjJKy1HtyeWj3QPMM844ZBFMdzRgQjay +ezmuKjNRmm2lMvZaQe5gP5bGGntLFx0dAiyM0b33RACk4iVht5U/6YbzNY6kUAq1FXa LGsWjLDpmzt68HP2EKKgQwptDZaYEPaC8VoFNanuZn8xvvNJ9oxH0KWILT9CIpR9rrxs O+ww== X-Gm-Message-State: AOJu0Yx3sFbT+D0H9SOEdhOArKSuehfV13VIAUtzWeVOJDd2X5Y3R/Vw +spKTgG+faQSq+/B7eFr/jRQFBkAKYcGgVKfEQUTPMJLw9r49w/uFGbKjAtB40sI X-Gm-Gg: AeBDieuS+cSab8XvwYzlgt3oXycknp9gzLxdwhYJSnL51SzDBFapX8zPLl4grRn3G8X DUZG18AWtj3bRfD8UVCr8psdbELBU8BhyEZzCYxreNsJO0rb40IPvZ6E2Vorfatzd//ueilsjIH Tes4ClmAGQKdJf4Avje1TCv/9snanR3YM7Q7bzVB95AmccSpDDyjIQ66lfiX9pXW75y2t3jEACz 0LibkJ2ffY1P/5GGnMbKL5rLLM12r5XljV/yGR910F5XOL+RRR8h1TiVE4UUD9SqbqDHL0qUFdY lxO1iMx67uC2xiu18MvdrYEWO/2gv++N5fGoTooDHv8U2nWijzzW7v7gzWmI8ydyi8rJA5i+NCN ETpbKnn7AfVaTMZOq93gxBtID5DTI92Rj8D7cRHduK/QdlCLN8PH6KQZwV8l2p5V4cOs1SDSprf j/AJyo52uSvUjk2YlQd0YcrRj+FQc= X-Received: by 2002:a05:6a20:4306:b0:39b:8b8b:39de with SMTP id adf61e73a8af0-3a398e5fe82mr5130648637.5.1777475895329; Wed, 29 Apr 2026 08:18:15 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-834ed5d036csm2852036b3a.24.2026.04.29.08.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2026 08:18:14 -0700 (PDT) From: DaeMyung Kang To: pgsql-hackers@lists.postgresql.org Cc: DaeMyung Kang Subject: [PATCH] Fix EINTR retry condition in pg_flush_data sync_file_range path. Date: Thu, 30 Apr 2026 00:18:11 +0900 Message-ID: <20260429151811.1810874-1-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.43.0" Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------2.43.0 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit Hi, Hackers, While auditing src/backend/storage/file, I spotted a small but unambiguous bug in pg_flush_data()'s sync_file_range() retry path. Details below in the commit message; the fix is a one-token change. Thanks, DaeMyung --- The retry branch compared the syscall return value (rc) against EINTR, but sync_file_range() returns -1 on error and reports the actual errno out-of-band, so rc == EINTR was always false and the retry was dead code. When sync_file_range() was actually interrupted by a signal, control fell through to the warning/error path instead of retrying. Compare errno instead, matching the convention already used elsewhere in this file (e.g. the pg_pread/pg_pwrite EINTR retries) and a few lines down for ENOSYS in this same block. --- src/backend/storage/file/fd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --------------2.43.0 Content-Type: text/x-patch; name="0001-Fix-EINTR-retry-condition-in-pg_flush_data-sync_file.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-Fix-EINTR-retry-condition-in-pg_flush_data-sync_file.patch" diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index a8be066afe0..817855e2720 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -563,7 +563,7 @@ retry: { int elevel; - if (rc == EINTR) + if (errno == EINTR) goto retry; /* --------------2.43.0--