mirror of https://github.com/citusdata/citus.git
Fix worker crash when coordinator disconnects
parent
73e1d81bb3
commit
667280650d
|
@ -48,31 +48,42 @@ RedirectCopyDataToRegularFile(const char *filename)
|
||||||
|
|
||||||
fileDesc = FileOpenForTransmit(filename, fileFlags, fileMode);
|
fileDesc = FileOpenForTransmit(filename, fileFlags, fileMode);
|
||||||
|
|
||||||
SendCopyInStart();
|
PG_TRY();
|
||||||
|
|
||||||
copyDone = ReceiveCopyData(copyData);
|
|
||||||
while (!copyDone)
|
|
||||||
{
|
{
|
||||||
/* if received data has contents, append to regular file */
|
|
||||||
if (copyData->len > 0)
|
SendCopyInStart();
|
||||||
|
|
||||||
|
copyDone = ReceiveCopyData(copyData);
|
||||||
|
while (!copyDone)
|
||||||
{
|
{
|
||||||
|
/* if received data has contents, append to regular file */
|
||||||
|
if (copyData->len > 0)
|
||||||
|
{
|
||||||
#if (PG_VERSION_NUM >= 100000)
|
#if (PG_VERSION_NUM >= 100000)
|
||||||
int appended = FileWrite(fileDesc, copyData->data, copyData->len,
|
int appended = FileWrite(fileDesc, copyData->data, copyData->len,
|
||||||
PG_WAIT_IO);
|
PG_WAIT_IO);
|
||||||
#else
|
#else
|
||||||
int appended = FileWrite(fileDesc, copyData->data, copyData->len);
|
int appended = FileWrite(fileDesc, copyData->data, copyData->len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (appended != copyData->len)
|
if (appended != copyData->len)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errcode_for_file_access(),
|
ereport(ERROR, (errcode_for_file_access(),
|
||||||
errmsg("could not append to received file: %m")));
|
errmsg("could not append to received file: %m")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
resetStringInfo(copyData);
|
resetStringInfo(copyData);
|
||||||
copyDone = ReceiveCopyData(copyData);
|
copyDone = ReceiveCopyData(copyData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
PG_CATCH();
|
||||||
|
{
|
||||||
|
FreeStringInfo(copyData);
|
||||||
|
FileClose(fileDesc);
|
||||||
|
PG_RE_THROW();
|
||||||
|
}
|
||||||
|
PG_END_TRY();
|
||||||
|
|
||||||
FreeStringInfo(copyData);
|
FreeStringInfo(copyData);
|
||||||
FileClose(fileDesc);
|
FileClose(fileDesc);
|
||||||
|
|
Loading…
Reference in New Issue