pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #13888: pg_dump write error
11+ messages / 6 participants
[nested] [flat]
* BUG #13888: pg_dump write error
@ 2016-01-25 14:30 kunschikov@gmail.com
2016-01-25 16:08 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 11+ messages in thread
From: kunschikov@gmail.com @ 2016-01-25 14:30 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 13888
Logged by: Vladimir Kunschikov
Email address: kunschikov@gmail.com
PostgreSQL version: 9.4.5
Operating system: Linux
Description:
Database backup in heavy loaded environment sometimes fails with the
following error:
pg_dump: [parallel archiver] could not write to output file: Success
Subsequent rerun of the pg_dump solves that problem.
More elegant and reliable solution: WRITE_ERROR_EXIT macro replacement in
ahwrite() function at src/bin/pg_dump/pg_backup_archiver.c source file.
There can be some error checking instead of this macro.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: BUG #13888: pg_dump write error
2016-01-25 14:30 BUG #13888: pg_dump write error kunschikov@gmail.com
@ 2016-01-25 16:08 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2016-01-26 07:21 ` Re: BUG #13888: pg_dump write error Vladimir Kunschikov <kunschikov@gmail.com>
2016-01-26 13:14 ` Re: BUG #13888: pg_dump write error Michael Paquier <michael.paquier@gmail.com>
0 siblings, 2 replies; 11+ messages in thread
From: Alvaro Herrera @ 2016-01-25 16:08 UTC (permalink / raw)
To: kunschikov@gmail.com; +Cc: pgsql-bugs
kunschikov@gmail.com wrote:
> Database backup in heavy loaded environment sometimes fails with the
> following error:
>
> pg_dump: [parallel archiver] could not write to output file: Success
>
> Subsequent rerun of the pg_dump solves that problem.
> More elegant and reliable solution: WRITE_ERROR_EXIT macro replacement in
> ahwrite() function at src/bin/pg_dump/pg_backup_archiver.c source file.
> There can be some error checking instead of this macro.
Yeah, I noticed this and similar lacks of error checks in pg_dump in
code review, which I didn't get around to patching. Care to submit a
patch?
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: BUG #13888: pg_dump write error
2016-01-25 14:30 BUG #13888: pg_dump write error kunschikov@gmail.com
2016-01-25 16:08 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2016-01-26 07:21 ` Vladimir Kunschikov <kunschikov@gmail.com>
1 sibling, 0 replies; 11+ messages in thread
From: Vladimir Kunschikov @ 2016-01-26 07:21 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: pgsql-bugs
Attached small refactoring of the ahwrite() which includes checking of the
errno.
It was made with postgres-9.4.5 sources but applicable to 9.4.1 and even to
9.5.0 with small fuss at ExecuteSqlCommandBuf() call
It could be done with small check of the errno with rerun without any
refactoring.
On Mon, Jan 25, 2016 at 7:08 PM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:
> kunschikov@gmail.com wrote:
>
> > Database backup in heavy loaded environment sometimes fails with the
> > following error:
> >
> > pg_dump: [parallel archiver] could not write to output file: Success
> >
> > Subsequent rerun of the pg_dump solves that problem.
> > More elegant and reliable solution: WRITE_ERROR_EXIT macro replacement
> in
> > ahwrite() function at src/bin/pg_dump/pg_backup_archiver.c source file.
> > There can be some error checking instead of this macro.
>
> Yeah, I noticed this and similar lacks of error checks in pg_dump in
> code review, which I didn't get around to patching. Care to submit a
> patch?
>
> --
> Álvaro Herrera http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
pg_backup_archiver.c.eagain.patch (text/x-patch, 3.6K) download
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 046611c..c78566c 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -1503,6 +1503,49 @@ dump_lo_buf(ArchiveHandle *AH)
AH->lo_buf_used = 0;
}
+/*
+ * ahwrite() blob writing helper
+ * handles blob output to the AH memory
+ * */
+static void write_blob(const void *ptr, size_t remaining, ArchiveHandle *AH)
+{
+ while (AH->lo_buf_used + remaining > AH->lo_buf_size)
+ {
+ size_t avail = AH->lo_buf_size - AH->lo_buf_used;
+
+ memcpy((char *) AH->lo_buf + AH->lo_buf_used, ptr, avail);
+ ptr = (const void *) ((const char *) ptr + avail);
+ remaining -= avail;
+ AH->lo_buf_used += avail;
+ dump_lo_buf(AH);
+ }
+
+ memcpy((char *) AH->lo_buf + AH->lo_buf_used, ptr, remaining);
+ AH->lo_buf_used += remaining;
+}
+
+/*
+ * ahwrite() output helper
+ * handles write of the `nmbemb` units `size` bytes each
+ * returns actual written byte count
+ * */
+static size_t write_units(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
+{
+ if (AH->gzOut)
+ return GZWRITE(ptr, size, nmemb, AH->OF);
+
+ if (AH->CustomOutPtr)
+ return AH->CustomOutPtr (AH, ptr, size * nmemb);
+
+ /*
+ * If we're doing a restore, and it's direct to DB, and we're
+ * connected then send it to the DB.
+ */
+ if (RestoringToDB(AH))
+ return ExecuteSqlCommandBuf(AH, (const char *) ptr, size * nmemb);
+
+ return fwrite(ptr, size, nmemb, AH->OF) * size;
+}
/*
* Write buffer to the output file (usually stdout). This is used for
@@ -1513,49 +1556,28 @@ dump_lo_buf(ArchiveHandle *AH)
void
ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
{
- int bytes_written = 0;
-
- if (AH->writingBlob)
- {
- size_t remaining = size * nmemb;
+ size_t bytes_written = 0;
+ size_t units_written = 0;
+ size_t write_attempts = 2;
+ size_t bytes_total = nmemb * size;
- while (AH->lo_buf_used + remaining > AH->lo_buf_size)
- {
- size_t avail = AH->lo_buf_size - AH->lo_buf_used;
-
- memcpy((char *) AH->lo_buf + AH->lo_buf_used, ptr, avail);
- ptr = (const void *) ((const char *) ptr + avail);
- remaining -= avail;
- AH->lo_buf_used += avail;
- dump_lo_buf(AH);
- }
+ if(AH->writingBlob)
+ return write_blob(ptr, bytes_total, AH);
- memcpy((char *) AH->lo_buf + AH->lo_buf_used, ptr, remaining);
- AH->lo_buf_used += remaining;
+ do{
+ bytes_written += write_units((uint8_t*)ptr + bytes_written, size, nmemb - units_written, AH);
- bytes_written = size * nmemb;
- }
- else if (AH->gzOut)
- bytes_written = GZWRITE(ptr, size, nmemb, AH->OF);
- else if (AH->CustomOutPtr)
- bytes_written = AH->CustomOutPtr (AH, ptr, size * nmemb);
-
- else
- {
- /*
- * If we're doing a restore, and it's direct to DB, and we're
- * connected then send it to the DB.
- */
- if (RestoringToDB(AH))
- bytes_written = ExecuteSqlCommandBuf(AH, (const char *) ptr, size * nmemb);
- else
- bytes_written = fwrite(ptr, size, nmemb, AH->OF) * size;
- }
+ if(bytes_written % size){
+ //unit was partially written. Switching to the one byte unit length in attempt to save unit remains anyway
+ size = 1;
+ nmemb = bytes_total;
+ }
- if (bytes_written != size * nmemb)
- WRITE_ERROR_EXIT;
+ units_written = bytes_written/size;
+ }while(bytes_written != bytes_total && (errno == EAGAIN || !errno) && write_attempts--);
- return;
+ if (bytes_written != bytes_total)
+ WRITE_ERROR_EXIT;
}
/* on some error, we may decide to go on... */
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: BUG #13888: pg_dump write error
2016-01-25 14:30 BUG #13888: pg_dump write error kunschikov@gmail.com
2016-01-25 16:08 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2016-01-26 13:14 ` Michael Paquier <michael.paquier@gmail.com>
2016-01-26 14:35 ` Re: BUG #13888: pg_dump write error Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 11+ messages in thread
From: Michael Paquier @ 2016-01-26 13:14 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: pgsql-bugs
On Tue, Jan 26, 2016 at 1:08 AM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> kunschikov@gmail.com wrote:
>
>> Database backup in heavy loaded environment sometimes fails with the
>> following error:
>>
>> pg_dump: [parallel archiver] could not write to output file: Success
>>
>> Subsequent rerun of the pg_dump solves that problem.
>> More elegant and reliable solution: WRITE_ERROR_EXIT macro replacement in
>> ahwrite() function at src/bin/pg_dump/pg_backup_archiver.c source file.
>> There can be some error checking instead of this macro.
>
> Yeah, I noticed this and similar lacks of error checks in pg_dump in
> code review, which I didn't get around to patching. Care to submit a
> patch?
Indeed, with a closer look there are things like tarWrite that can
return 0 and trigger WRITE_ERROR_EXIT with the same thing. Couldn't we
simply check for errno = 0 and generate a more generic error message
instead? Or are you willing at replacing all those things with just
exit_horribly()?
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: BUG #13888: pg_dump write error
2016-01-25 14:30 BUG #13888: pg_dump write error kunschikov@gmail.com
2016-01-25 16:08 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
2016-01-26 13:14 ` Re: BUG #13888: pg_dump write error Michael Paquier <michael.paquier@gmail.com>
@ 2016-01-26 14:35 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-01-27 01:27 ` Re: BUG #13888: pg_dump write error Michael Paquier <michael.paquier@gmail.com>
2016-01-27 06:14 ` Re: BUG #13888: pg_dump write error Vladimir Kunschikov <kunschikov@gmail.com>
2016-01-27 11:33 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 3 replies; 11+ messages in thread
From: Tom Lane @ 2016-01-26 14:35 UTC (permalink / raw)
To: Michael Paquier <michael.paquier@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; pgsql-bugs
Michael Paquier <michael.paquier@gmail.com> writes:
> On Tue, Jan 26, 2016 at 1:08 AM, Alvaro Herrera
> <alvherre@2ndquadrant.com> wrote:
>> Yeah, I noticed this and similar lacks of error checks in pg_dump in
>> code review, which I didn't get around to patching. Care to submit a
>> patch?
> Indeed, with a closer look there are things like tarWrite that can
> return 0 and trigger WRITE_ERROR_EXIT with the same thing. Couldn't we
> simply check for errno = 0 and generate a more generic error message
> instead? Or are you willing at replacing all those things with just
> exit_horribly()?
I do not understand these claims that there isn't an error check there.
There surely is. But fwrite() didn't set errno.
The real question is why did he get a short write in the first place.
We don't make any attempt to support filesystems that require retries,
which seems to be what is going on here. Should we?
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: BUG #13888: pg_dump write error
2016-01-25 14:30 BUG #13888: pg_dump write error kunschikov@gmail.com
2016-01-25 16:08 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
2016-01-26 13:14 ` Re: BUG #13888: pg_dump write error Michael Paquier <michael.paquier@gmail.com>
2016-01-26 14:35 ` Re: BUG #13888: pg_dump write error Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-01-27 01:27 ` Michael Paquier <michael.paquier@gmail.com>
2 siblings, 0 replies; 11+ messages in thread
From: Michael Paquier @ 2016-01-27 01:27 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; pgsql-bugs
On Tue, Jan 26, 2016 at 11:35 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Michael Paquier <michael.paquier@gmail.com> writes:
>> On Tue, Jan 26, 2016 at 1:08 AM, Alvaro Herrera
>> <alvherre@2ndquadrant.com> wrote:
>>> Yeah, I noticed this and similar lacks of error checks in pg_dump in
>>> code review, which I didn't get around to patching. Care to submit a
>>> patch?
>
>> Indeed, with a closer look there are things like tarWrite that can
>> return 0 and trigger WRITE_ERROR_EXIT with the same thing. Couldn't we
>> simply check for errno = 0 and generate a more generic error message
>> instead? Or are you willing at replacing all those things with just
>> exit_horribly()?
>
> I do not understand these claims that there isn't an error check there.
> There surely is. But fwrite() didn't set errno.
Yep, and the error message provided let's the user think that there
has been a failure, with a success. I am wondering about something
like that:
-#define WRITE_ERROR_EXIT \
+#define WRITE_ERROR_EXIT(errno) \
do { \
- exit_horribly(modulename, "could not write to output
file: %s\n", \
- strerror(errno)); \
+ if (errno != 0) \
+ exit_horribly(modulename, "could not write to
output file: %s\n", \
+ strerror(errno)); \
+ else \
+ exit_horribly(modulename, "could not write to
output file\n"); \
} while (0)
A more invasive approach would be to actually replace most of the
READ/WRITE_ERROR_EXIT stuff by more appropriate error checks with
customized error messages. And I would prefer that, this helps having
a deeper understanding of exactly where the error occurred when
running pg_dump.
> The real question is why did he get a short write in the first place.
> We don't make any attempt to support filesystems that require retries,
> which seems to be what is going on here. Should we?
I would keep the code simple, we don't do that in the backend I recall.
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: BUG #13888: pg_dump write error
2016-01-25 14:30 BUG #13888: pg_dump write error kunschikov@gmail.com
2016-01-25 16:08 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
2016-01-26 13:14 ` Re: BUG #13888: pg_dump write error Michael Paquier <michael.paquier@gmail.com>
2016-01-26 14:35 ` Re: BUG #13888: pg_dump write error Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-01-27 06:14 ` Vladimir Kunschikov <kunschikov@gmail.com>
2 siblings, 0 replies; 11+ messages in thread
From: Vladimir Kunschikov @ 2016-01-27 06:14 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Michael Paquier <michael.paquier@gmail.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; pgsql-bugs
pg_dump: could not write to output file: Success
>We don't make any attempt to support filesystems that require retries
Filesystem: VFAT on usb media.Seems like short write was caused not by
filesystem but by gzwrite(), since pg_dump was called with `-F d` switch:
pg_dump -U *** -d **** -v -j 2 -t "alert_counters" -t "aggr_alert_counters"
-t "alerts*" -t "payloads*" -F d -f
"/media/usb0/backup_963871436_2016-01-18_09-16-12"
I think there was EAGAIN error. We are solving this problem now by
suggesting to users rerun of the backup script. I've attached small patch
to the ahwrite() function in my previous posting (it is waiting for the
moderation approval ).
On Tue, Jan 26, 2016 at 5:35 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Michael Paquier <michael.paquier@gmail.com> writes:
> > On Tue, Jan 26, 2016 at 1:08 AM, Alvaro Herrera
> > <alvherre@2ndquadrant.com> wrote:
> >> Yeah, I noticed this and similar lacks of error checks in pg_dump in
> >> code review, which I didn't get around to patching. Care to submit a
> >> patch?
>
> > Indeed, with a closer look there are things like tarWrite that can
> > return 0 and trigger WRITE_ERROR_EXIT with the same thing. Couldn't we
> > simply check for errno = 0 and generate a more generic error message
> > instead? Or are you willing at replacing all those things with just
> > exit_horribly()?
>
> I do not understand these claims that there isn't an error check there.
> There surely is. But fwrite() didn't set errno.
>
> The real question is why did he get a short write in the first place.
> We don't make any attempt to support filesystems that require retries,
> which seems to be what is going on here. Should we?
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: BUG #13888: pg_dump write error
2016-01-25 14:30 BUG #13888: pg_dump write error kunschikov@gmail.com
2016-01-25 16:08 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
2016-01-26 13:14 ` Re: BUG #13888: pg_dump write error Michael Paquier <michael.paquier@gmail.com>
2016-01-26 14:35 ` Re: BUG #13888: pg_dump write error Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-01-27 11:33 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2016-02-02 21:12 ` Re: BUG #13888: pg_dump write error Tom Lane <tgl@sss.pgh.pa.us>
2 siblings, 1 reply; 11+ messages in thread
From: Alvaro Herrera @ 2016-01-27 11:33 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Michael Paquier <michael.paquier@gmail.com>; pgsql-bugs
Tom Lane wrote:
> Michael Paquier <michael.paquier@gmail.com> writes:
> > On Tue, Jan 26, 2016 at 1:08 AM, Alvaro Herrera
> > <alvherre@2ndquadrant.com> wrote:
> >> Yeah, I noticed this and similar lacks of error checks in pg_dump in
> >> code review, which I didn't get around to patching. Care to submit a
> >> patch?
>
> > Indeed, with a closer look there are things like tarWrite that can
> > return 0 and trigger WRITE_ERROR_EXIT with the same thing. Couldn't we
> > simply check for errno = 0 and generate a more generic error message
> > instead? Or are you willing at replacing all those things with just
> > exit_horribly()?
>
> I do not understand these claims that there isn't an error check there.
> There surely is. But fwrite() didn't set errno.
Yeah, that's what I was remembering actually:
http://www.postgresql.org/message-id/20150608174336.GM133018@postgresql.org
> The real question is why did he get a short write in the first place.
> We don't make any attempt to support filesystems that require retries,
> which seems to be what is going on here. Should we?
Sounds likely.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: BUG #13888: pg_dump write error
2016-01-25 14:30 BUG #13888: pg_dump write error kunschikov@gmail.com
2016-01-25 16:08 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
2016-01-26 13:14 ` Re: BUG #13888: pg_dump write error Michael Paquier <michael.paquier@gmail.com>
2016-01-26 14:35 ` Re: BUG #13888: pg_dump write error Tom Lane <tgl@sss.pgh.pa.us>
2016-01-27 11:33 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2016-02-02 21:12 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-02-02 21:56 ` Re: BUG #13888: pg_dump write error Andres Freund <andres@anarazel.de>
0 siblings, 1 reply; 11+ messages in thread
From: Tom Lane @ 2016-02-02 21:12 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Michael Paquier <michael.paquier@gmail.com>; pgsql-bugs
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Tom Lane wrote:
>> I do not understand these claims that there isn't an error check there.
>> There surely is. But fwrite() didn't set errno.
> Yeah, that's what I was remembering actually:
> http://www.postgresql.org/message-id/20150608174336.GM133018@postgresql.org
>> The real question is why did he get a short write in the first place.
>> We don't make any attempt to support filesystems that require retries,
>> which seems to be what is going on here. Should we?
> Sounds likely.
Actually, now that I think about it while not in an airport, what I
think we really need is logic along the lines of
errno = 0;
nbytes = fwrite(...);
if (nbytes != expected && errno == 0)
errno = ENOSPC;
ie, assume a short write implies out-of-disk-space. I believe that
is what we do in most (hopefully all) cases in the backend; see for
example UpdateControlFile() in xlog.c.
IMO it is not really WRITE_ERROR_EXIT's place to assume that errno == 0
should be replaced by ENOSPC; in particular, that would be incorrect,
or at least insufficient, unless there's an explicit initialization of
"errno = 0;" before the fwrite call. So I'm inclined to put the
responsibility to do all of the above logic on the fwrite call sites,
rather than splitting it between callers and WRITE_ERROR_EXIT.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: BUG #13888: pg_dump write error
2016-01-25 14:30 BUG #13888: pg_dump write error kunschikov@gmail.com
2016-01-25 16:08 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
2016-01-26 13:14 ` Re: BUG #13888: pg_dump write error Michael Paquier <michael.paquier@gmail.com>
2016-01-26 14:35 ` Re: BUG #13888: pg_dump write error Tom Lane <tgl@sss.pgh.pa.us>
2016-01-27 11:33 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
2016-02-02 21:12 ` Re: BUG #13888: pg_dump write error Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-02-02 21:56 ` Andres Freund <andres@anarazel.de>
2016-02-02 22:32 ` Re: BUG #13888: pg_dump write error Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 11+ messages in thread
From: Andres Freund @ 2016-02-02 21:56 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Michael Paquier <michael.paquier@gmail.com>; pgsql-bugs
On February 2, 2016 10:12:54 PM GMT+01:00, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>Actually, now that I think about it while not in an airport, what I
>think we really need is logic along the lines of
>
> errno = 0;
> nbytes = fwrite(...);
> if (nbytes != expected && errno == 0)
> errno = ENOSPC;
>
>ie, assume a short write implies out-of-disk-space. I believe that
>is what we do in most (hopefully all) cases in the backend; see for
>example UpdateControlFile() in xlog.c.
There's an exception: when writing WAL we intentionally retry on short writes. IIRC Heikki added that after we found a case where large writes returned short, but non zero, and trying again to finish the rest works. I'm nor sure of there aren't other cases where that should be done, die to large writes.
Andres
---
Please excuse brevity and formatting - I am writing this on my mobile phone.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: BUG #13888: pg_dump write error
2016-01-25 14:30 BUG #13888: pg_dump write error kunschikov@gmail.com
2016-01-25 16:08 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
2016-01-26 13:14 ` Re: BUG #13888: pg_dump write error Michael Paquier <michael.paquier@gmail.com>
2016-01-26 14:35 ` Re: BUG #13888: pg_dump write error Tom Lane <tgl@sss.pgh.pa.us>
2016-01-27 11:33 ` Re: BUG #13888: pg_dump write error Alvaro Herrera <alvherre@2ndquadrant.com>
2016-02-02 21:12 ` Re: BUG #13888: pg_dump write error Tom Lane <tgl@sss.pgh.pa.us>
2016-02-02 21:56 ` Re: BUG #13888: pg_dump write error Andres Freund <andres@anarazel.de>
@ 2016-02-02 22:32 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 11+ messages in thread
From: Tom Lane @ 2016-02-02 22:32 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Michael Paquier <michael.paquier@gmail.com>; pgsql-bugs
Andres Freund <andres@anarazel.de> writes:
> On February 2, 2016 10:12:54 PM GMT+01:00, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> ie, assume a short write implies out-of-disk-space. I believe that
>> is what we do in most (hopefully all) cases in the backend; see for
>> example UpdateControlFile() in xlog.c.
> There's an exception: when writing WAL we intentionally retry on short writes. IIRC Heikki added that after we found a case where large writes returned short, but non zero, and trying again to finish the rest works. I'm nor sure of there aren't other cases where that should be done, die to large writes.
I could support making pg_dump do that if there's a way to do it when
writing through zlib (which is probably the normal case these days).
I'm not at all sure that gzwrite() is retryable after a partial write;
that would likely have consequences for the internal state of the
compressor.
In any case, if you get nbytes == 0 and errno == 0, substituting ENOSPC
seems like the right thing.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 11+ messages in thread
end of thread, other threads:[~2016-02-02 22:32 UTC | newest]
Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-01-25 14:30 BUG #13888: pg_dump write error kunschikov@gmail.com
2016-01-25 16:08 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2016-01-26 07:21 ` Vladimir Kunschikov <kunschikov@gmail.com>
2016-01-26 13:14 ` Michael Paquier <michael.paquier@gmail.com>
2016-01-26 14:35 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-01-27 01:27 ` Michael Paquier <michael.paquier@gmail.com>
2016-01-27 06:14 ` Vladimir Kunschikov <kunschikov@gmail.com>
2016-01-27 11:33 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2016-02-02 21:12 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-02-02 21:56 ` Andres Freund <andres@anarazel.de>
2016-02-02 22:32 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox