Subject RE: [firebird-support] fb server crash in multi thread,connection table creation
Author Alan McDonald
So each thread is creating the same set of tables? BB1 BB2 etc???
whatever did you expect to happen when you commit 30 attempts to create the
same table?
Alan

> -----Original Message-----
> From: kartinku [mailto:kartinku@...]
> Sent: Saturday, November 20, 2004 5:51 PM
> To: firebird-support@yahoogroups.com
> Subject: [firebird-support] fb server crash in multi thread,connection
> table creation
>
>
>
>
> Dear Members ,
> I am doing some scalability testing of firebird DB. During my test
> firebird database server has got killed. I have spawn multiple threads
> an in each I have created tables with a connection in each thread. Is
> there is any thereshold limit for firebird server in terms of
> memory,connection etc. If so kindly detail me or provide any
> linkdetailing the same,
>
> I spawn 20 threads simultaneously. In each thread I got FB (Super
> server , 1.5.1 release version) db server connection through driver
> manager. In each thread I kept creating table (30 in each thread)
> in autocommit false. I have set JVM memory has 20MB. But I got
> exception like below.
>
> Exception :
> org.firebirdsql.gds.GDSException: Error reading data from the connection.
> ull
> at
> org.firebirdsql.jgds.GDS_Impl.receiveResponse(GDS_Impl.java:1784)
> at
> org.firebirdsql.jgds.GDS_Impl.isc_commit_transaction(GDS_Impl.java:593)
> at
> org.firebirdsql.jca.FBManagedConnectionFactory.commit(FBManagedCon
> nectionFactory.ja
> at
> org.firebirdsql.jca.FBManagedConnection.internalCommit(FBManagedCo
> nnection.java:411
> at
> org.firebirdsql.jca.FBLocalTransaction.internalCommit(FBLocalTrans
> action.java:155)
> at
> org.firebirdsql.jdbc.AbstractConnection.commit(AbstractConnection.
> java:372)
> at org.firebirdsql.jdbc.FBConnection.commit(FBConnection.java:52)
> at
> TestMultiConnection$ChildCreate.run(TestMultiConnection.java:114)
> at java.lang.Thread.run(Thread.java:536)
>
> firebird server has got killed.
>
>
> When I run the same program in embedded server I have got below
> exception and program has got hanged. When I have taken a thread dump
> , all threads has got hanged in commit. method
>
> Exception :
>
> org.firebirdsql.ngds.InternalError: Unexpected exception caught.
> at
> org.firebirdsql.ngds.GDS_Impl.native_isc_commit_transaction(Native Method)
> at
> org.firebirdsql.ngds.GDS_Impl.isc_commit_transaction(GDS_Impl.java:455)
> at
> org.firebirdsql.jca.FBManagedConnectionFactory.commit(FBManagedCon
> nectionFactory.java:708)
> at
> org.firebirdsql.jca.FBManagedConnection.internalCommit(FBManagedCo
> nnection.java:411)
> at
> org.firebirdsql.jca.FBLocalTransaction.internalCommit(FBLocalTrans
> action.java:155)
> at
> org.firebirdsql.jdbc.AbstractConnection.commit(AbstractConnection.
> java:372)
> at org.firebirdsql.jdbc.FBConnection.commit(FBConnection.java:52)
> at
> TestMultiConnection$ChildCreate.run(TestMultiConnection.java:115)
> at java.lang.Thread.run(Thread.java:536)
>
>
> I am not sure whether is this an issue or expected behaviour. If I
> am wrong kindly clarify me. And I feel issue will be firebird DB. So
> I have forwarded the issue to both java and support forums. I have
> uploded my test program in firebird -java --> File. File name is
> TestMultiConnection.java. I have pasted the same testprogram at the
> end of this mail. If there is any flaw in my program kindly let me
> know about it.
>
> Environment :
> O.S : Windows 2000 professional
> FB : firebird 1.5.1.4481
> Jaybird : 1.5.4
> JDK : 1.4.1_03
>
>
> import java.sql.*;
> import java.util.*;
> import java.util.logging.*;
>
> public class TestMultiConnection
> {
>
> int counter=0;
> boolean autoCommit = false;
> int number=20; // indicates numeber od threads/connection
> int step = 30; // no of table to be created in each thread
> int total=600; // total no of tables i.e number * step
> public TestMultiConnection(String[] args) throws Exception
> {
> autoCommit = (new Boolean(args[0])).booleanValue();
> //number = Integer.parseInt(args[1]);
> //step = Integer.parseInt(args[2]);
> doTheBusiness();
> }
>
> Connection conn = null;
> public Connection getConnection()
> throws Exception
> {
>
> String driverName = "org.firebirdsql.jdbc.FBDriver";
> String jdbcUrl =
> "jdbc:firebirdsql:localhost/3050:c:/webserver/htdocs/thirdparty/fi
> rebird/actual_FB/installed/examples/TEST2.FDB";
> // jdbcUrl =
> "jdbc:firebirdsql:embedded:c:/webserver/htdocs/thirdparty/firebird
> /actual_FB/installed/examples/TEST2.FDB";
> //String jdbcUrl =
> "jdbc:firebirdsql:localhost/3050:c:/webserver/htdocs/thirdparty/fi
> rebird/ourEmbed/loadtest/windows/db/MICKEY2.FDB";
> Class.forName (driverName);
> java.sql.Driver d = java.sql.DriverManager.getDriver (jdbcUrl);
> Connection conn = java.sql.DriverManager.getConnection
> (jdbcUrl, "sysdba" , "masterkey");
>
> conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
> conn.setAutoCommit(autoCommit);
> return conn;
> }
>
>
>
>
> private void doTheBusiness()
> throws Exception
> {
> //create 5 threads
> Thread[] ths = new Thread[number];
> counter=0;
>
> //start the threads
> for(int i=0; i<number; i++)
> {
> int temp=counter+step;
> ChildCreate child = new ChildCreate();
> //set range oif tables to be create , 1..20 , 21 ..40 etc
> child.setRange(counter,temp);
> ths[i] = new Thread(child,"C-"+i+":");
> ths[i].start();
> counter =temp;
> }
>
> //wait till all threads gets completed
> for(int i=0; i<number; i++)
> {
> ths[i].join();
> }
>
> }
>
>
> class ChildCreate implements Runnable
> {
>
> ChildCreate()
> {
> }
>
>
>
> int start=-1, end=-1;
> void setRange(int start , int end)
> {
> this.start = start;
> this.end = end;
> }
>
>
> public void run()
> {
> try
> {
> Random rd = new Random();
> Connection c = null;
> try
> {
> c = getConnection();
> for (int i=start; i<end; i++)
> {
> String sql = "create table BB"+i +"(ID INTEGER
> NOT NULL PRIMARY KEY)";
> Statement statement= c.createStatement();
> statement.executeUpdate(sql);
> statement.close();
> }
> if(!c.getAutoCommit())
> {
> c.commit();
> }
> }
> catch(Exception e)
> {
> if(!c.getAutoCommit())
> {
> c.rollback();
> }
> e.printStackTrace();
> }
> finally
> {
> c.close();
> }
> }
> catch(Exception e)
> {
> System.err.println("ERROR : FIX : ");
> e.printStackTrace();
> }
> }
> }
>
>
> public static void main(String[] args)
> throws Exception
> {
> new TestMultiConnection(args);
> }
> }// TestMultiConnection
>
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>