View Issue Details

IDProjectCategoryView StatusLast Update
0000230Pgpool-IIBugpublic2016-08-09 19:29
ReporterysobjAssigned Tot-ishii 
PriorityurgentSeveritymajorReproducibilityalways
Status resolvedResolutionopen 
Product Version3.5.1 
Target Version3.5.4Fixed in Version 
Summary0000230: pgpool does not return result set if the statement fetchSize is smaller than the result row count.
Descriptionpgpool: 3.5.1
postgresql: 9.5.3
pgpool configuration: replication_mode=off, master_slave_mode=on, master_slave_sub_mode='stream'
java version: 1.8.0_25
JdbcDriverVersion: 9.4.1209.jre7

pgpool does not return result set if the statement fetchSize is smaller than the result row count.
Steps To ReproduceD:\test>javac -cp postgresql-9.4.1209.jre7.jar Sample.java
D:\test>java -cp postgresql-9.4.1209.jre7.jar;. Sample >result.log 2>&1


source code to reproduce this problem is following.

---
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;

import org.postgresql.Driver;

public class Sample {
    public Sample() {
    }

    public static void main(String[] args) throws Exception {
        Properties props = new Properties();
        props.setProperty("user", "test");
        props.setProperty("password", "test");
        DriverManager.setLogWriter(new PrintWriter(System.out));
        Driver.setLogLevel(2);
        Connection conn = DriverManager.getConnection(
                "jdbc:postgresql://xxx.xxx.xxx.xxx:9999/test", props);
        conn.setAutoCommit(false);
        Statement st = conn.createStatement();
        st.setFetchSize(100);
        ResultSet rs = st.executeQuery("SELECT * from GENERATE_SERIES(1,1000)");
        while (rs.next()) {
            System.out.println(rs.getString(1));
        }
        rs.close();
    }
}
---

This problem is not present in 3.5.0
I think this problem has occured by a changeset a6f15a0 'Fix extended query hangs'.
TagsNo tags attached.

Activities

ysobj

2016-08-09 11:30

reporter  

result.log (144,085 bytes)

t-ishii

2016-08-09 17:08

developer   ~0000972

Last edited: 2016-08-09 17:09

View 2 revisions

Good catch. Pgpool-II in streaming replication mode needs to handle when it receives "Portan Suspend" message from backend, so that it waits for input from clients. Attached patch should fix the problem. Can you please try the patch?

t-ishii

2016-08-09 17:09

developer  

portalsuspend.diff (558 bytes)
diff --git a/src/protocol/pool_proto_modules.c b/src/protocol/pool_proto_modules.c
index 6eb7716..a32563e 100644
--- a/src/protocol/pool_proto_modules.c
+++ b/src/protocol/pool_proto_modules.c
@@ -2518,7 +2518,7 @@ POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend,
 
 			case 's':	/* PortalSuspended */
 				status = SimpleForwardToFrontend(kind, frontend, backend);
-				if ((REPLICATION || RAW_MODE) && pool_is_doing_extended_query_message())
+				if (pool_is_doing_extended_query_message())
 					pool_unset_query_in_progress();
 				break;
 
portalsuspend.diff (558 bytes)

ysobj

2016-08-09 17:34

reporter   ~0000973

Thank you. I will try this patch.

ysobj

2016-08-09 18:10

reporter   ~0000974

I tested reproduce code and our product.
This patch works fine for me.
Thank your quick fixs.

Do you have a plan for v3.5.4 release?

t-ishii

2016-08-09 18:13

developer   ~0000975

Yes, we are going to release 3.5.4 by the end of August.

Issue History

Date Modified Username Field Change
2016-08-09 11:30 ysobj New Issue
2016-08-09 11:30 ysobj File Added: result.log
2016-08-09 14:15 t-ishii Assigned To => t-ishii
2016-08-09 14:15 t-ishii Status new => assigned
2016-08-09 14:15 t-ishii Steps to Reproduce Updated View Revisions
2016-08-09 17:08 t-ishii Note Added: 0000972
2016-08-09 17:09 t-ishii Note Edited: 0000972 View Revisions
2016-08-09 17:09 t-ishii File Added: portalsuspend.diff
2016-08-09 17:09 t-ishii Status assigned => feedback
2016-08-09 17:18 t-ishii Target Version => 3.5.4
2016-08-09 17:34 ysobj Note Added: 0000973
2016-08-09 17:34 ysobj Status feedback => assigned
2016-08-09 18:10 ysobj Note Added: 0000974
2016-08-09 18:13 t-ishii Note Added: 0000975
2016-08-09 19:29 t-ishii Status assigned => resolved