Enhance gpfdist error log
Print errno and message if local_send() fails.
Print detail information on session end
@@ -1181,7 +1181,11 @@ static int local_send(request_t *r, const char* buf, int buflen)
if (r->session)
session_end(r->session, 0);
} else {
- gdebug(r, "gpfdist_send failed - due to (%d: %s)", e, strerror(e));
+ if (!ok) {
+ gwarning(r, "gpfdist_send failed - due to (%d: %s)", e, strerror(e));
+ } else {
+ gdebug(r, "gpfdist_send failed - due to (%d: %s), should try again", e, strerror(e));
+ }
}
return ok ? 0 : -1;
}
@@ -1347,13 +1351,14 @@ session_get_block(const request_t* r, block_t* retblock, char* line_delim_str, i
/* finish the session - close the file */
static void session_end(session_t* session, int error)
{
- gprintln(NULL, "session end.");
+ gprintln(NULL, "session end. id = %ld, is_error = %d, error = %d", session->id, session->is_error, error);
if (error)
session->is_error = error;
if (session->fstream)
{
+ gprintln(NULL, "close fstream");
fstream_close(session->fstream);
session->fstream = 0;
}
@@ -1775,6 +1780,10 @@ static void do_write(int fd, short event, void* arg)
n = local_send(r, datablock->hdr.hbyte + datablock->hdr.hbot, n);
if (n < 0)
{
+ /*
+ * TODO: It is not safe to check errno here, should check and
+ * return special value in local_send()
+ */
if (errno == EPIPE || errno == ECONNRESET)
r->outblock.bot = r->outblock.top;
request_end(r, 1, "gpfdist send block header failure");
