Thread: server restart when connections thread over 155 in PostgreSQL 8.03

PostgreSQL version: 8.03<p>Operating system: windows xp<p>In my config file:<p>max_connections = 300<p>My test program
justcreates 200 threads to perform some simple query task. I find<p>server often restart when the 155th connection
threadstartup.<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>atTestDBConnection.main(TestDBConnection.java:48)<p>End
ofStack 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>atjava.sql.DriverManager.getConnection(DriverManager.java:512)<p>at
java.sql.DriverManager.getConnection(DriverManager.java:171)<p>at
TestDBConnection.main(TestDBConnection.java:48)<p>===================================================<p>errorsin
log:<p>2005-06-2901: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-2901:52:08 WARNING: terminating connection because of crash of<p>another server
process<p>2005-06-2901:52:08 DETAIL: The postmaster has commanded this server<p>process to roll back the current
transactionand exit, because another<p>server process exited abnormally and possibly corrupted shared
memory.<p>2005-06-2901:52:08 HINT: In a moment you should be able to reconnect to<p>the database and repeat your
command.<p>2005-06-2901:52:08 WARNING: terminating connection because of crash of<p>another server process<p>2005-06-29
01:52:08DETAIL: The postmaster has commanded this server<p>process to roll back the
current<p>========================================<p>MyJava code :<p>import java.sql.Connection;<p>import
java.sql.DriverManager;<p>importjava.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>publicvoid 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>staticObject lock = new Object();<p>public static void main(String[] args) {<p>try
{<p>Class.forName("org.postgresql.Driver");<p>intnum = 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
(Throwablee) {<p>e.printStackTrace();<p>}
<p>}<p>}<p>=================================================================================<p>Mytable
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=#