Hi Charles,
Thank for the response,
as you suggest to me, I have repeated the test using the sedna driver;
below there is the code that I've used for new test.

With this code it can load 20 resources simultaneously.


In the test with the Sedna XML:DB API I have tried to eliminate the row of
code where I close the collection
(in tis manner I never use a "recycled" Database Socket connection) and so
there are no problems.

It seems that the problem occurs when I use "recycled" collection.

Code with sedna driver
import ru.ispras.sedna.driver.*;
public class Test2 {
    public Test2() {
        removeAll();
        int numThread = 20;
        final Thread[] listThread = new Thread[numThread];
        for (int i = 0; i < numThread; i++) {
            final int count = i;
            listThread[i] = new Thread(new Runnable() {
                public void run() {
                    SednaConnection conn = getConnection();
                    try {
                        conn.begin();
                        SednaStatement st1 = conn.createStatement();
                        boolean call_res = st1.execute("LOAD
\"c:\\test.xml\" \"a" + count + "\"");
                        conn.commit();
                    } catch (Exception e) {
                        try {
                            conn.rollback();
                        } catch (DriverException e1) {
                            e1.printStackTrace();
                        }
                        System.out.println(e);
                    } finally {
                        try {
                            conn.close();
                        } catch (DriverException e) {
                            e.printStackTrace();
                        }
                    }

                }

            });

        }
        long ini = System.currentTimeMillis();
        for (int i = 0; i < numThread; i++) {
            listThread[i].start();
        }

        for (int i = 0; i < numThread; i++) {
            try {
                listThread[i].join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("fine totale:" + (System.currentTimeMillis() -
ini));
    }

    private SednaConnection getConnection() {
        SednaConnection con = null;
        String url = "localhost";
        String dbname = "Test";
        String user = "SYSTEM";
        String password = "MANAGER";
        try {
            con = DatabaseManager.getConnection(url, dbname, user,
password);
        } catch (DriverException e) {
            e.printStackTrace();
        }
        return con;
    }

...

    public static void main(String[] args) {
        Test2 t2 = new Test2();
    }
}






2009/7/28 Charles Foster <[email protected]>

> Hi Michele,
>
> I've spoken to you about this before privately and explained to you that
> investigating this problem would take a long time indeed.
>
> It appears that the code creates 10 concurrent connections and "open
> transactions" on the database at the same time.
>
> Have you tried opening 10 connections with an according 10 concurrent
> OPEN-transactions on the Database with either Sedna Team MODIS Driver or
> even se_term? Or even getting the same thing to work with the Team MODIS
> Java driver?
>
> Are you aware that the following code:
>
> DatabaseManager.getCollection(String, String, String)
>
> will create you a brand new Sedna Connection / Socket?
>
> Please investigate as much as you can about this and identifying where the
> issue resides (Sedna XML Database or Sedna XML:DB Driver), The fact the
> error message is SEDNA Message: ERROR SE4703... would suggest it is at the
> Server end, but please first find this out.
>
> Regards,
>
> Charles
>
> > Hi,
> >
> > I've encountered a problem when I try to use a Sedna XML:DB API for Java
> > in
> > a multithreading application.
> >
> > When more than one thread try to store a different resource in the same
> > collection and the operation is bounded in one transaction I get the
> > following error:
> >
> > SEDNA Message: ERROR SE4703 The transaction is a victim of deadlock
> > resolution procedure.
> >
> > This is the test code for replicate the problem:
> >
> >
> >
> >
> > import org.xmldb.api.DatabaseManager;
> > import org.xmldb.api.base.Collection;
> > import org.xmldb.api.base.Database;
> > import org.xmldb.api.base.Resource;
> > import org.xmldb.api.base.XMLDBException;
> > import org.xmldb.api.modules.CollectionManagementService;
> > import org.xmldb.api.modules.TransactionService;
> > import org.xmldb.api.modules.XMLResource;
> >
> > public class Test3 {
> >  public Test3() throws Exception {
> >
> >   Database sednaDatabase;
> >   Class<?> clazz = Class.forName("net.cfoster.sedna.DatabaseImpl");
> >   sednaDatabase = (Database) (clazz.newInstance());
> >   DatabaseManager.registerDatabase(sednaDatabase);
> >
> >   int numThread = 10;
> >   final Thread[] listThread = new Thread[numThread];
> >
> >   for (int i = 0; i < numThread; i++) {
> >
> >    final int count = i;
> >
> >    listThread[i] = new Thread(new Runnable() {
> >     public void run() {
> >      Collection root = null;
> >      TransactionService transactionService = null;
> >      try {
> >       root =
> > DatabaseManager.getCollection("xmldb:sedna://localhost:5050/Test",
> > "SYSTEM",
> > "MANAGER");
> >       transactionService = (TransactionService)
> > root.getService("TransactionService", "1.0");
> >       transactionService.begin();
> >       Resource r = root.createResource("test" + count,
> > XMLResource.RESOURCE_TYPE);
> >       r.setContent("<test/>");
> >       root.storeResource(r);
> >       transactionService.commit();
> >      } catch (Exception e) {
> >       e.printStackTrace();
> >       try {
> >        transactionService.rollback();
> >       } catch (XMLDBException e1) {
> >        e1.printStackTrace();
> >       }
> >      } finally {
> >       try {
> >        root.close();
> >       } catch (Exception e) {
> >        e.printStackTrace();
> >       }
> >      }
> >
> >     }
> >
> >    });
> >
> >   }
> >   System.out.println("init");
> >   for (int i = 0; i < numThread; i++) {
> >    listThread[i].start();
> >   }
> >
> >   for (int i = 0; i < numThread; i++) {
> >    listThread[i].join();
> >   }
> >   System.out.println("end");
> >   System.exit(0);
> >  }
> >
> >
> >
> >  public static void main(String[] args) {
> >   try {
> >    new Test3();
> >   } catch (Exception e) {
> >    e.printStackTrace();
> >   }
> >  }
> > }
> >
> ------------------------------------------------------------------------------
> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> > 30-Day
> > trial. Simplify your report design, integration and deployment - and
> focus
> > on
> > what you do best, core application coding. Discover what's new with
> > Crystal Reports now.
> >
> http://p.sf.net/sfu/bobj-july_______________________________________________
> > Sedna-discussion mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/sedna-discussion
> >
>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Sedna-discussion mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sedna-discussion
>
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Sedna-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sedna-discussion

Reply via email to