Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jjPHG-0007I3-DK for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Jun 2020 15:38:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jjPHF-0003rk-Bx for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Jun 2020 15:38:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jjPHF-0003qw-4r for pgsql-hackers@lists.postgresql.org; Thu, 11 Jun 2020 15:38:01 +0000 Received: from mail-io1-xd42.google.com ([2607:f8b0:4864:20::d42]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jjPHA-0004qs-Vv for pgsql-hackers@postgresql.org; Thu, 11 Jun 2020 15:38:00 +0000 Received: by mail-io1-xd42.google.com with SMTP id o5so6757947iow.8 for ; Thu, 11 Jun 2020 08:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=06xE5IatRCQDldnLPGDZy2y5WSabVSac1Ixu6TsOyA0=; b=NCQdtpHhj7/Ij3Go4QhNByF3HYbtClIEP6MXg3Ug39WJWmkKunCEDmBr/fcrH9H7sv zflNHqNQaqiCUHvpdREgXL1tH6y8KoAQUtO8wz7OtzafyJhpOfGeo/0Y3Ad/hdS4/QQ+ FkAjFWX1dvsgcz1FYBpABB+oViA/aWi+n4bSHrW3Dl2V9o9svrzqnYKlL6R3RVxqsaMj 5mVqSCwNq65Qct+YdGtABVKAXd2mBTm7WKYM/Sd1eYlcNYyrK/S6BGgSgbx8siI2FzpU VnILIaGMfRLguoEKKGFWEk50SHWwocxZfijBY1KicsstgDDTqvyi8+Iat5abHHuKOdJv Gxkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=06xE5IatRCQDldnLPGDZy2y5WSabVSac1Ixu6TsOyA0=; b=ll5WKjLZcp+MKnyxvh+BhJWtuypU32kGugEZ3Ae+qTRnhJBy+OK+C+N8CPocqavVg+ QapGmFh91XkQ/3mhNNLef99eateTDroJzpGM1f416VPfHgSOQnVNDrvbRDONZveTk0zr 0tcMLK0F6gDL+D26YJW58S0Ya2gt5MLwMEcCRuOpz5GkTymaNc28/ypaq7DXkeO70cfd nGK15kCdrtSknZBnL+zLRuEdhYDV80JaYoQfCEmcyg/7I9W0TYhniaxVZrW6IUPiH2d6 DccFeURp6Yy9S2iGkAQkjRn8utcmaxG0t5zUhEoHGU3CID08rb81Vs3qR0aNeQRxCtwd D8Zg== X-Gm-Message-State: AOAM533TnZhJoKdue7TnQ/VnXI1L8b0bfQSTnr2ar65RpTx+FtrKC9AV jZL5KvkoTwrrKVtMo0T/jZwYgg== X-Google-Smtp-Source: ABdhPJxe5/o/UKPbqspABasPnAalaq0yH4bc7AWtukqAM7BA092tOu2Hy71p8sZiqcDlX++2pELc6A== X-Received: by 2002:a05:6602:146:: with SMTP id v6mr8927850iot.170.1591889874998; Thu, 11 Jun 2020 08:37:54 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id v16sm1681175ilo.47.2020.06.11.08.37.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jun 2020 08:37:54 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 37E5480090D; Thu, 11 Jun 2020 10:37:53 -0500 (CDT) Date: Thu, 11 Jun 2020 10:37:53 -0500 From: Justin Pryzby To: pgsql-hackers@postgresql.org Cc: Alvaro Herrera , Kunshchikov Vladimir Subject: pg_dump, gzwrite, and errno Message-ID: <20200611153753.GU14879@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk While testing Pavel's patch for pg_dump --filter, I got: pg_dump: error: could not write to output file: Success [pryzbyj@database postgresql]$ echo $? 1 I see we tried to fix it few years ago: https://www.postgresql.org/message-id/flat/1498120508308.9826%40infotecs.ru https://www.postgresql.org/message-id/flat/20160125143008.2539.2878%40wrigleys.postgresql.org https://www.postgresql.org/message-id/20160307.174354.251049100.horiguchi.kyotaro@lab.ntt.co.jp https://www.postgresql.org/message-id/20150608174336.GM133018@postgresql.org Commits: 4d57e83816778c6f61ea35c697f937a6f9c3c3de 9a3b5d3ad0f1c19c47e2ee65b372344cb0616c9a This patch fixes it for me pg_dump: error: could not write to output file: No space left on device --- a/src/bin/pg_dump/pg_backup_directory.c +++ b/src/bin/pg_dump/pg_backup_directory.c @@ -347,8 +347,12 @@ _WriteData(ArchiveHandle *AH, const void *data, size_t dLen) lclContext *ctx = (lclContext *) AH->formatData; if (dLen > 0 && cfwrite(data, dLen, ctx->dataFH) != dLen) + { + if (errno == 0) + errno = ENOSPC; fatal("could not write to output file: %s", get_cfp_error(ctx->dataFH)); + } } PS. Due to $UserError, I originally sent this message with inaccurate RFC822 headers..