pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedpgpool master or slave goes down java access error
2+ messages / 2 participants
[nested] [flat]
* pgpool master or slave goes down java access error
@ 2011-08-12 10:58 jenopob <jenopob@126.com>
0 siblings, 1 reply; 2+ messages in thread
From: jenopob @ 2011-08-12 10:58 UTC (permalink / raw)
To: pgsql-performance
hi pgpool Expert
my architecture as follows:
Master/Slave with Streaming Replication and pgpool-II
version of pgpool-II is pgpool-II.3.0.4
version of PostgreSQL is 9.0.2
I am using pgpool works as master/slave sub mode stream
and pgpool key configuration is:
=====================================================================================================
num_init_children=100
max_pool=4
child_life_time=60
connection_life_time=0
child_max_connections=0
client_idle_limit=0
connection_cache=true
=====================================================================================================
and java jdbc connection test code as fllows:
=====================================================================================================
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class TestPgpool {
public static void main(String[] args) {
for(;;){
Thread th = new Thread(new TestThread());
th.start();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
System.out.println("1--------------");
e.printStackTrace();
System.out.println("1--------------");
}
}
}
static class TestThread implements Runnable{
public void run() {
Connection con = null;
Statement stmt = null;
try {
Class.forName("org.postgresql.Driver");
con = DriverManager.getConnection(
"jdbc:postgresql://192.168.1.116:9999/spring250_20100630_705",
"postgres","postgres");
stmt = con.createStatement();
String sql = "SELECT * FROM bb_member limit 1";
ResultSet rs = stmt.executeQuery(sql);
System.out.print("OK(");
while(rs.next()){
System.out.print(rs.getInt(1) + "="
+ rs.getString(2) + " ");
}
System.out.println(")");
stmt.close();
con.close();
} catch (SQLException e) {
System.out.println("2--------------");
e.printStackTrace();
System.out.println("2--------------");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
}
=====================================================================================================
question:
I do some db falt tests
1)the test code run always connect pgpool,
2)test master or slave go down
but when mster or slave go down ,java code throws exception :
org.postgresql.util.PSQLException: An I/O error occurred while sending to
the backend
org.postgresql.util.PSQLException: The connection attempt failed.
the error happened once for little time,then goes normal.
what should I do to solve this problem?and show the reason about the matter.
thanks for any help
jeno
--
View this message in context: http://postgresql.1045698.n5.nabble.com/pgpool-master-or-slave-goes-down-java-access-error-tp4692837...
Sent from the PostgreSQL - performance mailing list archive at Nabble.com.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: pgpool master or slave goes down java access error
@ 2011-08-12 16:44 Waldo Nell <pwnell@telkomsa.net>
parent: jenopob <jenopob@126.com>
0 siblings, 0 replies; 2+ messages in thread
From: Waldo Nell @ 2011-08-12 16:44 UTC (permalink / raw)
To: pgsql-performance
On 2011-08-12, at 03:58 , jenopob wrote:
>
> I do some db falt tests
> 1)the test code run always connect pgpool,
> 2)test master or slave go down
>
> but when mster or slave go down ,java code throws exception :
>
> org.postgresql.util.PSQLException: An I/O error occurred while sending to
> the backend
> org.postgresql.util.PSQLException: The connection attempt failed.
>
> the error happened once for little time,then goes normal.
>
> what should I do to solve this problem?and show the reason about the matter.
I do not know much about pgpool but it sounds to me like the TCP connection is broken, and threads die and new threads make new connections they start working again. If I understand you correctly, you need to write code that detects this IOException and then retries the connection attempt and re-execute the query.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2011-08-12 16:44 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-08-12 10:58 pgpool master or slave goes down java access error jenopob <jenopob@126.com>
2011-08-12 16:44 ` Waldo Nell <pwnell@telkomsa.net>
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