pgpool2.git / summary / log / commit / refs
commit 73a6eb8c2e2a11e96a8bb303a06d5694a1a682d7
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Mon Jul 30 01:08:08 2012 +0000
If frontend terminates while reading large number of query results
from backend, pgpool continues to read from backend and write to
frontend until all query results consumued. This will take very long
time if query results is huge. To finish pgpool session as soon as
possible, modify pool_flush_it to returns error if fail to write to
frontend when operated in other than replication mode. In replication
mode, we need to keep the previous behavior to save consistency among
backends(maybe this is not true anymore, since all write queres are
executed in a transaction in replication mode?).
Also fix SimpleForwardToFrontend to return pool_write_and_flush
error status. Before it was ignored.
pool_process_query.c | 6 +++++-
pool_stream.c | 10 +++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/pool_process_query.c b/pool_process_query.c
index c3973d5f7..3a0554984 100644
--- a/pool_process_query.c
+++ b/pool_process_query.c
@@ -1103,7 +1103,11 @@ POOL_STATUS SimpleForwardToFrontend(char kind, POOL_CONNECTION *frontend,
pool_write(frontend, &kind, 1);
sendlen = htonl(len1+4);
pool_write(frontend, &sendlen, sizeof(sendlen));
- pool_write_and_flush(frontend, p1, len1);
+ if (pool_write_and_flush(frontend, p1, len1) < 0)
+ {
+ pool_error("SimpleForwardToFrontend: pool_write_and_flush failed");
+ return POOL_END;
+ }
/* save the received result for each kind */
if (pool_config->enable_query_cache && SYSDB_STATUS == CON_UP)
diff --git a/pool_stream.c b/pool_stream.c
index 804a3836d..9fdf47c45 100644
--- a/pool_stream.c
+++ b/pool_stream.c
@@ -509,10 +509,14 @@ int pool_flush(POOL_CONNECTION *cp)
else
{
/*
- * ignore error on frontend. we need to continue the
- * processing with backends
+ * If we are in replication mode, we need to continue the
+ * processing with backends to keep consistency among
+ * backends, thus ignore error.
*/
- return 0;
+ if (REPLICATION)
+ return 0;
+ else
+ return -1;
}
}
return 0;
[parent: d82a59e91f23]