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.94.2) (envelope-from ) id 1qWIMv-002mg7-OJ for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Aug 2023 15:23:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qWIMu-007cz4-Bc for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Aug 2023 15:23:32 +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.94.2) (envelope-from ) id 1qWIMu-007cyw-1q for pgsql-hackers@lists.postgresql.org; Wed, 16 Aug 2023 15:23:32 +0000 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qWIMr-000Slc-5H for pgsql-hackers@postgresql.org; Wed, 16 Aug 2023 15:23:30 +0000 Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3a43cbb432aso5190962b6e.3 for ; Wed, 16 Aug 2023 08:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692199408; x=1692804208; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=mPKnevo3LKpOMPhNIoINo/4JhAEfxMkuZFd08+sQ48g=; b=Q1MvqOOAbrwkH0R11vfrt9AWZYqe9LuwS9c85n+b/cIRJ+9aDvv9GJVb2l9o/fzU6l 1f9VEeoLziguQt2q0wXraUOKFxYD/L0COASLJ9Y6a+GLPXI/xdgv/5+u7qGqQMOcUQ0i JxqirlIzGUipITQmUa1+fZ0PDCKZ4qh79jdaY7ihKZUDCku47ua8cMEwtalmfbHgvUB8 Xue+9AWpDGLIi8FI6T0VzLWBv2FA6vKkh9kbywuZaz714C/wrqAdFmnSKQwvLhZ9ygby lMK1TBDkvxjDIIXbBf6U+Q5rj5RKbbP7z6p8DrSqlVcesGQ15iI9YFKvxmp8eu3epzry QVMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692199408; x=1692804208; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mPKnevo3LKpOMPhNIoINo/4JhAEfxMkuZFd08+sQ48g=; b=b4CCYn9Vr90S8vjpFNuaQVBBEWzcKeegr5G5PkLpTFf/D3aqpKEd37WpnJ29ixzMNr a35p/uEiJZkS9U1fHBYZLj7qP7jpBFCEX6qOtZS2WU8RgN2jjTqTuxlC1m4e+3PpSKDu LbGYwHJ7qsNAiWYB1iR6r+Z9qdRvd/ZBC8aIq9y19x/7odXmgRVkjIKrxYi15rg5yi6d 5RtyeN+mig4g5zIufj76jrsogcax3s+huyq9b7gH8DH85w4n8olpPnUzx0T6x/3YF7l4 DB0SBL0kQPjEtYMFOowjYym0QDmCWFnp5WFFAgy/8nWpto6OYTr6D5ibnJRT6b0ETQDv A2Uw== X-Gm-Message-State: AOJu0Yx0jxGvpYf3+kZv2vkaxjXdARm2BPyJKFTvWv+CC0RtYhmYgGHD nC5dmYBmzN1jgZ8XBfzIgmE= X-Google-Smtp-Source: AGHT+IEWfCWRnuEHRodMsXolt4ovyiNQjtU66lHI16iRe9WCRgpjgcf4WNC+6D1Ll0i0+9KKwqwTkw== X-Received: by 2002:a05:6808:10c5:b0:3a7:2524:6d46 with SMTP id s5-20020a05680810c500b003a725246d46mr3147379ois.59.1692199408517; Wed, 16 Aug 2023 08:23:28 -0700 (PDT) Received: from nathanxps13 ([2600:1700:48f8:340f:4f4c:44bb:6856:3082]) by smtp.gmail.com with ESMTPSA id o8-20020a0568080bc800b003a75593746asm6563305oik.57.2023.08.16.08.23.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 08:23:27 -0700 (PDT) Date: Wed, 16 Aug 2023 08:23:25 -0700 From: Nathan Bossart To: Michael Paquier Cc: Justin Pryzby , Thomas Munro , David Steele , Fujii Masao , Bruce Momjian , Tom Lane , Michael Brown , pgsql-hackers@postgresql.org Subject: Re: should frontend tools use syncfs() ? Message-ID: <20230816152325.GC2651383@nathanxps13> References: <20210930004340.GM831@telsasoft.com> <20220413115412.GM26620@telsasoft.com> <20230729214010.GA189456@nathanxps13> <20230731175138.GA432880@nathanxps13> <20230731183946.GB537853@nathanxps13> <20230801163707.GA862840@nathanxps13> <20230808200606.GA1384393@nathanxps13> <20230816151705.GB2651383@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230816151705.GB2651383@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Aug 16, 2023 at 08:17:05AM -0700, Nathan Bossart wrote: > On Wed, Aug 16, 2023 at 08:10:10AM +0900, Michael Paquier wrote: >> + pg_log_error("could not synchronize file system for file \"%s\": %m", path); >> + (void) close(fd); >> + exit(EXIT_FAILURE); >> >> walkdir() reports errors and does not consider these fatal. Why the >> early exit()? > > I know it claims to, but fsync_fname() does exit when fsync() fails: > > returncode = fsync(fd); > > /* > * Some OSes don't allow us to fsync directories at all, so we can ignore > * those errors. Anything else needs to be reported. > */ > if (returncode != 0 && !(isdir && (errno == EBADF || errno == EINVAL))) > { > pg_log_error("could not fsync file \"%s\": %m", fname); > (void) close(fd); > exit(EXIT_FAILURE); > } > > I suspect that the current code does not treat failures for things like > open() as fatal because it's likely due to a lack of permissions on the > file, but it does treat failures to fsync() as fatal because it is more > likely to indicate that ѕomething is very wrong. I don't know whether this > reasoning is sound, but I tried to match the current convention in the > syncfs() code. Ah, it looks like this code used to treat fsync() errors as non-fatal, but it was changed in commit 1420617. I still find it a bit strange that some errors that prevent a file from being sync'd are non-fatal while others _are_ fatal, but that is probably a topic for another thread. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com