PostgreSQL version: 8.03<p>Operating system: windows xp<p>In my config file:<p>max_connections = 300<p>My test program just creates 200 threads to perform some simple query task. I find<p>server often restart when the 155th connection thread startup.<p>======================================================<p>console information:<p>.......<p>at 153<p>at 154<p>org.postgresql.util.PSQLException: An I/O error occured while reading from<p>backend - Exception: java.net.SocketException: Connection reset<p>Stack Trace:<p>java.net.SocketException: Connection reset<p>at java.net.SocketInputStream.read(SocketInputStream.java:168)<p>at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)<p>at java.io.BufferedInputStream.read(BufferedInputStream.java:201)<p>at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:166)<p>at<p>org.postgresql.jdbc1.AbstractJdbc1Connection.openConnectionV3(AbstractJdbc1C<p>onnection.java:301)<p>at<p>org.postgresql.jdbc1.AbstractJdbc1Connection.open
Connection(AbstractJdbc1Con<p>nection.java:214)<p>at org.postgresql.Driver.connect(Driver.java:139)<p>at java.sql.DriverManager.getConnection(DriverManager.java:512)<p>at java.sql.DriverManager.getConnection(DriverManager.java:171)<p>at TestDBConnection.main(TestDBConnection.java:48)<p>End of Stack Trace<p>at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:172)<p>at<p>org.postgresql.jdbc1.AbstractJdbc1Connection.openConnectionV3(AbstractJdbc1C<p>onnection.java:301)<p>at<p>org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Con<p>nection.java:214)<p>at org.postgresql.Driver.connect(Driver.java:139)<p>at java.sql.DriverManager.getConnection(DriverManager.java:512)<p>at java.sql.DriverManager.getConnection(DriverManager.java:171)<p>at TestDBConnection.main(TestDBConnection.java:48)<p>===================================================<p>errors in log:<p>2005-06-29 01:49:42 LOG: unexpected EOF on client connection<p>2005-06-29 01:52:08 LOG: server pro
cess (PID 13764) exited with unexpected<p>status 128<p>2005-06-29 01:52:08 LOG: terminating any other active server processes<p>2005-06-29 01:52:08 WARNING: terminating connection because of crash of<p>another server process<p>2005-06-29 01:52:08 DETAIL: The postmaster has commanded this server<p>process to roll back the current transaction and exit, because another<p>server process exited abnormally and possibly corrupted shared memory.<p>2005-06-29 01:52:08 HINT: In a moment you should be able to reconnect to<p>the database and repeat your command.<p>2005-06-29 01:52:08 WARNING: terminating connection because of crash of<p>another server process<p>2005-06-29 01:52:08 DETAIL: The postmaster has commanded this server<p>process to roll back the current<p>========================================<p>My Java code :<p>import java.sql.Connection;<p>import java.sql.DriverManager;<p>import java.sql.ResultSet;<p>import java.sql.ResultSetMetaData;<p>import java.sql.SQLException;<p>publ
ic class TestDBConnection extends Thread{<p>TestDBConnection(int i, Connection conn){<p>this.order = i;<p>this.conn =conn;<p>}<p>public void run(){<p>try {<p>System.out.println("at " + order);<p>conn.createStatement().executeQuery("select * from book_status");<p>synchronized ("finished_task"){<p>finished++;<p>}<p>synchronized(lock){<p>lock.wait();<p>}<p>System.out.println("fat "+ order);<p>} catch (Throwable e) {<p>e.printStackTrace();<p>} <p>}<p>int order = 0;<p>Connection conn;<p>static int finished = 0;<p>static Object lock = new Object();<p>public static void main(String[] args) {<p>try {<p>Class.forName("org.postgresql.Driver");<p>int num = 200;<p>Thread[] ts = new Thread[num];<p>Connection[] cs = new Connection[num];<p>for (int i = 0; i < num; i++){<p>cs[i] = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test", "test", "test");<p>ts[i] = new TestDBConnection(i, cs[i]);<p>ts[i].start();<p>}<p>while (TestDBConnection.finished != num){<p>Thread.sleep(300);
<p>}<p>synchronized(lock){<p>lock.notifyAll();<p>}<p>for (int j = 0; j < num; j++){<p>cs[j].close();<p>}<p>} catch (Throwable e) {<p>e.printStackTrace();<p>} <p>}<p>}<p>=================================================================================<p>My table infomation:<p>test=# d book_status;<p>---------------+-----------------------+----------<p>bookid | character varying(64) | not null<p>length | integer |<p>lastupdate | character varying(16) |<p>curblock | integer |<p>downloadtimes | integer |<p>INDEX:<p>"book_status_pkey" PRIMARY KEY, btree (bookid)<p>test=#