POM / 1PC

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

POM / 1PC

joël Winteregg-2
Dear BTM users,


It's funny, because I discovered your Transaction Manager yesterday and
my both question were already partially asked during this week on this
mailing list ;-)

The first one was about Maven POM (I was looking for a POM file for
BTM). And the second one was about 1PC.
The good thing is that I learned that 1PC is automatically used when you
only have one DB (my case), but I'm not able to understand the behaviour
of SQL BEGIN and COMMIT within my UserTransaction.
I'm using BTM with postgresql 8.2 and Hibernate 3 (standalone
middleware) and when I look to my pgsql logs, BEGIN and COMMIT doesn't
match at all me UserTransaction.begin() and UserTransaction.commit()
calls.

When I check my pgsql logs using the given example
(http://docs.codehaus.org/display/BTM/Hibernate) every query seems to be
done between a BEGIN and COMMIT (which does not denote UserTransaction
boundaries):

2007-11-03 00:22:36 CET LOG:  execute <unnamed>: SELECT gid FROM
pg_prepared_xacts
2007-11-03 00:22:37 CET LOG:  execute S_1: BEGIN
2007-11-03 00:22:37 CET LOG:  execute <unnamed>: insert into USERS
(NAME) values ($1)
2007-11-03 00:22:37 CET DETAIL:  parameters: $1 = 'user'
2007-11-03 00:22:37 CET LOG:  execute S_2: COMMIT
2007-11-03 00:22:37 CET LOG:  execute S_1: BEGIN
2007-11-03 00:22:37 CET LOG:  execute <unnamed>: select
currval('USERS_id_seq')
2007-11-03 00:22:38 CET LOG:  execute S_2: COMMIT
2007-11-03 00:22:38 CET LOG:  execute S_1: BEGIN
2007-11-03 00:22:38 CET LOG:  execute <unnamed>: select user0_.id as
id0_, user0_.NAME as NAME0_ from USERS user0_
2007-11-03 00:22:38 CET LOG:  execute S_2: COMMIT

In my own application which is doing 100 Hibernate queries in a loop
(inside the same UserTransaction) the strange thing is that i only have
an SQL transaction (BEGIN / COMMIT) arround the first query and the 99
other are done outside any SQL transaction... Is there a way to control
this or is this the right behaviour ? or maybe I don't understand
something...
 
2007-11-02 19:43:04 CET LOG:  execute S_1: BEGIN
2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select count(*) as y0_
from table this_ where this_.detecttime between $1 and $2
2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-07-31
19:43:03.922+02', $2 = '2007-08-01 02:55:03.922+02'
2007-11-02 19:43:04 CET LOG:  execute S_2: COMMIT
2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select count(*) as y0_
from table this_ where this_.detecttime between $1 and $2
2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-01
02:55:03.922+02', $2 = '2007-08-01 10:07:03.922+02'
2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select count(*) as y0_
from table this_ where this_.detecttime between $1 and $2
2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-01
10:07:03.922+02', $2 = '2007-08-01 17:19:03.922+02'
2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select count(*) as y0_
from table this_ where this_.detecttime between $1 and $2
2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-01
17:19:03.922+02', $2 = '2007-08-02 00:31:03.922+02'
2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select count(*) as y0_
from table this_ where this_.detecttime between $1 and $2
2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-02
00:31:03.922+02', $2 = '2007-08-02 07:43:03.922+02'
2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select count(*) as y0_
from table this_ where this_.detecttime between $1 and $2
2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-02
07:43:03.922+02', $2 = '2007-08-02 14:55:03.922+02'


Many thanks in advance !

Best regards.

Joël



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: POM / 1PC

Ludovic Orban
Administrator
Hi Joël,

I've asked Laco to post his POM file. I hope he'll do it soon and that you'll find it useful. I'll jump on the occasion to get a bit more familiar with maven as well and check what added value it could bring to BTM.

What you see in the pgsql logs can make sense. It depends on basically every involved layer: the database itself, the JDBC driver, BTM, the Hibernate config and your own code.

It is nearly impossible to verify that you get consistent results without being capable of reproducing the entire behavior of your application. If you can make a downloadable archive with the relevant parts of your application available somewhere I'll have a look at it.

Ludovic

2007/11/3, joël Winteregg <[hidden email]>:
Dear BTM users,


It's funny, because I discovered your Transaction Manager yesterday and
my both question were already partially asked during this week on this
mailing list ;-)

The first one was about Maven POM (I was looking for a POM file for
BTM). And the second one was about 1PC.
The good thing is that I learned that 1PC is automatically used when you
only have one DB (my case), but I'm not able to understand the behaviour
of SQL BEGIN and COMMIT within my UserTransaction.
I'm using BTM with postgresql 8.2 and Hibernate 3 (standalone
middleware) and when I look to my pgsql logs, BEGIN and COMMIT doesn't
match at all me UserTransaction.begin() and UserTransaction.commit()
calls.

When I check my pgsql logs using the given example
(http://docs.codehaus.org/display/BTM/Hibernate) every query seems to be
done between a BEGIN and COMMIT (which does not denote UserTransaction
boundaries):

2007-11-03 00:22:36 CET LOG:  execute <unnamed>: SELECT gid FROM
pg_prepared_xacts
2007-11-03 00:22:37 CET LOG:  execute S_1: BEGIN
2007-11-03 00:22:37 CET LOG:  execute <unnamed>: insert into USERS
(NAME) values ($1)
2007-11-03 00:22:37 CET DETAIL:  parameters: $1 = 'user'
2007-11-03 00:22:37 CET LOG:  execute S_2: COMMIT
2007-11-03 00:22:37 CET LOG:  execute S_1: BEGIN
2007-11-03 00:22:37 CET LOG:  execute <unnamed>: select
currval('USERS_id_seq')
2007-11-03 00:22:38 CET LOG:  execute S_2: COMMIT
2007-11-03 00:22:38 CET LOG:  execute S_1: BEGIN
2007-11-03 00:22:38 CET LOG:  execute <unnamed>: select user0_.id as
id0_, user0_.NAME as NAME0_ from USERS user0_
2007-11-03 00:22:38 CET LOG:  execute S_2: COMMIT

In my own application which is doing 100 Hibernate queries in a loop
(inside the same UserTransaction) the strange thing is that i only have
an SQL transaction (BEGIN / COMMIT) arround the first query and the 99
other are done outside any SQL transaction... Is there a way to control
this or is this the right behaviour ? or maybe I don't understand
something...

2007-11-02 19:43:04 CET LOG:  execute S_1: BEGIN
2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select count(*) as y0_
from table this_ where this_.detecttime between $1 and $2
2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-07-31
19:43:03.922+02', $2 = '2007-08-01 02:55:03.922+02'
2007-11-02 19:43:04 CET LOG:  execute S_2: COMMIT
2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select count(*) as y0_
from table this_ where this_.detecttime between $1 and $2
2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-01
02:55:03.922+02', $2 = '2007-08-01 10:07:03.922+02'
2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select count(*) as y0_
from table this_ where this_.detecttime between $1 and $2
2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-01
10:07:03.922+02', $2 = '2007-08-01 17:19:03.922+02'
2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select count(*) as y0_
from table this_ where this_.detecttime between $1 and $2
2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-01
17:19:03.922+02', $2 = '2007-08-02 00:31:03.922+02'
2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select count(*) as y0_
from table this_ where this_.detecttime between $1 and $2
2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-02
00:31:03.922+02', $2 = '2007-08-02 07:43:03.922+02'
2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select count(*) as y0_
from table this_ where this_.detecttime between $1 and $2
2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-02
07:43:03.922+02', $2 = '2007-08-02 14:55:03.922+02'


Many thanks in advance !

Best regards.

Joël



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

     http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re:[btm-user] POM / 1PC

joël Winteregg-2
Hi Ludovic,

Many thanks for your answer ! Here is some more informations about my
application:

- All my implementation is based on the given example:
http://docs.codehaus.org/display/BTM/Hibernate

- My datasource declaration is as follow:

private static PoolingDataSource getDataSource_db1() {            
  PoolingDataSource ds = new PoolingDataSource();
  ds.setUniqueName("jdbc/hibernate");
  ds.setClassName("org.postgresql.xa.PGXADataSource");
  ds.setMaxPoolSize(3);
  ds.getDriverProperties().put("databaseName", "hibernate");
  ds.getDriverProperties().put("user", "hibernate");
  ds.getDriverProperties().put("password", "hibernate");
  ds.getDriverProperties().put("serverName", "127.0.0.1");
  ds.getDriverProperties().put("portNumber", "5432");
  ds.init();
  return ds;
}

- My query look like this (pseudo-code):
 0. UserTransaction.begin()
 1. do 100 times
 2.  sessionFactory.getCurrentSession()
 3.  do the hibernate Criteria query
 4. end do 100 times
 5. UserTransaction.commit()

- My hibernate config related to JTA is as follow:
<property name="current_session_context_class">jta</property>
<property
name="transaction.manager_lookup_class">BitronixTransactionManagerLookup</property>
<property
name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property
name="jta.UserTransaction">java:comp/UserTransaction</property>
<property name="connection.pool_size">10</property>


Any feedback would be appreciated !

Regarding, SQL BEGIN/COMMIT using the given example
http://docs.codehaus.org/display/BTM/Hibernate is that right that each
query should be done inside a BEGIN and COMMIT block, even if the
UserTransaction doesn't match this scope (as explained in my previous
email) ? Maybe I need some more reading about this, so do not hesitate
to point me on some paper about this...

Many thanks in advance.

Regards,


Joël

On Nov 3, 2007 3:15 PM , Ludovic Orban wrote:

> Hi Joël,
>
> I've asked Laco to post his POM file. I hope he'll do it soon and that
> you'll find it useful. I'll jump on the occasion to get a bit more
> familiar with maven as well and check what added value it could bring
> to BTM.
>
> What you see in the pgsql logs can make sense. It depends on basically
> every involved layer: the database itself, the JDBC driver, BTM, the
> Hibernate config and your own code.
>
> It is nearly impossible to verify that you get consistent results
> without being capable of reproducing the entire behavior of your
> application. If you can make a downloadable archive with the relevant
> parts of your application available somewhere I'll have a look at it.
>
> Ludovic
>
> 2007/11/3, joël Winteregg <[hidden email]>:
>         Dear BTM users,
>        
>        
>         It's funny, because I discovered your Transaction Manager
>         yesterday and
>         my both question were already partially asked during this week
>         on this
>         mailing list ;-)
>        
>         The first one was about Maven POM (I was looking for a POM
>         file for
>         BTM). And the second one was about 1PC.
>         The good thing is that I learned that 1PC is automatically
>         used when you
>         only have one DB (my case), but I'm not able to understand the
>         behaviour
>         of SQL BEGIN and COMMIT within my UserTransaction.
>         I'm using BTM with postgresql 8.2 and Hibernate 3 (standalone
>         middleware) and when I look to my pgsql logs, BEGIN and COMMIT
>         doesn't
>         match at all me UserTransaction.begin() and
>         UserTransaction.commit()
>         calls.
>        
>         When I check my pgsql logs using the given example
>         (http://docs.codehaus.org/display/BTM/Hibernate) every query
>         seems to be
>         done between a BEGIN and COMMIT (which does not denote
>         UserTransaction
>         boundaries):
>        
>         2007-11-03 00:22:36 CET LOG:  execute <unnamed>: SELECT gid
>         FROM
>         pg_prepared_xacts
>         2007-11-03 00:22:37 CET LOG:  execute S_1: BEGIN
>         2007-11-03 00:22:37 CET LOG:  execute <unnamed>: insert into
>         USERS
>         (NAME) values ($1)
>         2007-11-03 00:22:37 CET DETAIL:  parameters: $1 = 'user'
>         2007-11-03 00:22:37 CET LOG:  execute S_2: COMMIT
>         2007-11-03 00:22:37 CET LOG:  execute S_1: BEGIN
>         2007-11-03 00:22:37 CET LOG:  execute <unnamed>: select
>         currval('USERS_id_seq')
>         2007-11-03 00:22:38 CET LOG:  execute S_2: COMMIT
>         2007-11-03 00:22:38 CET LOG:  execute S_1: BEGIN
>         2007-11-03 00:22:38 CET LOG:  execute <unnamed>: select
>         user0_.id as
>         id0_, user0_.NAME as NAME0_ from USERS user0_
>         2007-11-03 00:22:38 CET LOG:  execute S_2: COMMIT
>        
>         In my own application which is doing 100 Hibernate queries in
>         a loop
>         (inside the same UserTransaction) the strange thing is that i
>         only have
>         an SQL transaction (BEGIN / COMMIT) arround the first query
>         and the 99
>         other are done outside any SQL transaction... Is there a way
>         to control
>         this or is this the right behaviour ? or maybe I don't
>         understand
>         something...
>        
>         2007-11-02 19:43:04 CET LOG:  execute S_1: BEGIN
>         2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select
>         count(*) as y0_
>         from table this_ where this_.detecttime between $1 and $2
>         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-07-31
>         19:43:03.922+02', $2 = '2007-08-01 02:55:03.922+02'
>         2007-11-02 19:43:04 CET LOG:  execute S_2: COMMIT
>         2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select
>         count(*) as y0_
>         from table this_ where this_.detecttime between $1 and $2
>         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-01
>         02:55:03.922+02', $2 = '2007-08-01 10:07:03.922+02'
>         2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select
>         count(*) as y0_
>         from table this_ where this_.detecttime between $1 and $2
>         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-01
>         10:07:03.922+02', $2 = '2007-08-01 17:19:03.922+02'
>         2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select
>         count(*) as y0_
>         from table this_ where this_.detecttime between $1 and $2
>         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-01
>         17:19:03.922+02', $2 = '2007-08-02 00:31:03.922+02'
>         2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select
>         count(*) as y0_
>         from table this_ where this_.detecttime between $1 and $2
>         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-02
>         00:31:03.922+02', $2 = '2007-08-02 07:43:03.922+02'
>         2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select
>         count(*) as y0_
>         from table this_ where this_.detecttime between $1 and $2
>         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-02
>         07:43:03.922+02', $2 = '2007-08-02 14:55:03.922+02'
>        
>        
>         Many thanks in advance !
>        
>         Best regards.
>        
>         Joël
>        
>        
>        
>        
>         ---------------------------------------------------------------------
>         To unsubscribe from this list, please visit:
>        
>              http://xircles.codehaus.org/manage_email
>        
>        
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re:[btm-user] POM / 1PC

Ludovic Orban
Administrator
Joël,

There is one major difference between your code and the one in the Hibernate example: your code does 100 queries in 1 transaction while the example's does 1 query per transaction. This probably explains the differences (at least partly) you see in the Postgres logs.

The fact that you see a begin/commit statement around only the first query still looks strange. I suspect your code to be responsible for this difference but could only confirm this if I had access to it. It might also be normal behavior of Postgres' JDBC driver. Maybe the logging logic is not precise enough or maybe the driver's a bit buggy.

At second look, I noticed this in your Hibernate config:

 <property name="connection.pool_size">10</property>

This is unneeded and confusing. Hibernate does not control the BTM datasource, it should only acquire it via JNDI. Now I wonder if that property is ignored or if it interferes somewhere. How did you configure the BTM PoolingDataSource ? How did you configure Hibernate to access it ? Could you try removing that connection.pool_size property and see if there is any difference ?


About your question
regarding SQL BEGIN/COMMIT, I don't really get it. What do you mean with UserTransaction that does not match scope ? The way it works is that any work done between begin() and commit() will be part of the same transaction, period. What do you find unclear ?

Ludovic


2007/11/4, joël Winteregg <[hidden email]>:
Hi Ludovic,

Many thanks for your answer ! Here is some more informations about my
application:

- All my implementation is based on the given example:
http://docs.codehaus.org/display/BTM/Hibernate

- My datasource declaration is as follow:

private static PoolingDataSource getDataSource_db1() {
  PoolingDataSource ds = new PoolingDataSource();
  ds.setUniqueName ("jdbc/hibernate");
  ds.setClassName("org.postgresql.xa.PGXADataSource");
  ds.setMaxPoolSize(3);
  ds.getDriverProperties().put("databaseName", "hibernate");
  ds.getDriverProperties ().put("user", "hibernate");
  ds.getDriverProperties().put("password", "hibernate");
  ds.getDriverProperties().put("serverName", "127.0.0.1 ");
  ds.getDriverProperties().put("portNumber", "5432");
  ds.init();
  return ds;
}

- My query look like this (pseudo-code):
0. UserTransaction.begin()
1. do 100 times
2.  sessionFactory.getCurrentSession()
3.  do the hibernate Criteria query
4. end do 100 times
5. UserTransaction.commit()

- My hibernate config related to JTA is as follow:
<property name="current_session_context_class">jta</property>
<property
name="transaction.manager_lookup_class">BitronixTransactionManagerLookup</property>
<property
name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory </property>
<property
name="jta.UserTransaction">java:comp/UserTransaction</property>
<property name="connection.pool_size">10</property>


Any feedback would be appreciated !

Regarding, SQL BEGIN/COMMIT using the given example
http://docs.codehaus.org/display/BTM/Hibernate is that right that each
query should be done inside a BEGIN and COMMIT block, even if the
UserTransaction doesn't match this scope (as explained in my previous
email) ? Maybe I need some more reading about this, so do not hesitate
to point me on some paper about this...

Many thanks in advance.

Regards,


Joël

On Nov 3, 2007 3:15 PM , Ludovic Orban wrote:

> Hi Joël,
>
> I've asked Laco to post his POM file. I hope he'll do it soon and that
> you'll find it useful. I'll jump on the occasion to get a bit more
> familiar with maven as well and check what added value it could bring
> to BTM.
>
> What you see in the pgsql logs can make sense. It depends on basically
> every involved layer: the database itself, the JDBC driver, BTM, the
> Hibernate config and your own code.
>
> It is nearly impossible to verify that you get consistent results
> without being capable of reproducing the entire behavior of your
> application. If you can make a downloadable archive with the relevant
> parts of your application available somewhere I'll have a look at it.
>
> Ludovic
>
> 2007/11/3, joël Winteregg <[hidden email] >:
>         Dear BTM users,
>
>
>         It's funny, because I discovered your Transaction Manager
>         yesterday and
>         my both question were already partially asked during this week
>         on this
>         mailing list ;-)
>
>         The first one was about Maven POM (I was looking for a POM
>         file for
>         BTM). And the second one was about 1PC.
>         The good thing is that I learned that 1PC is automatically
>         used when you
>         only have one DB (my case), but I'm not able to understand the
>         behaviour
>         of SQL BEGIN and COMMIT within my UserTransaction.
>         I'm using BTM with postgresql 8.2 and Hibernate 3 (standalone
>         middleware) and when I look to my pgsql logs, BEGIN and COMMIT
>         doesn't
>         match at all me UserTransaction.begin() and
>         UserTransaction.commit()
>         calls.
>
>         When I check my pgsql logs using the given example
>         ( http://docs.codehaus.org/display/BTM/Hibernate) every query
>         seems to be
>         done between a BEGIN and COMMIT (which does not denote
>         UserTransaction
>         boundaries):
>
>         2007-11-03 00:22:36 CET LOG:  execute <unnamed>: SELECT gid
>         FROM
>         pg_prepared_xacts
>         2007-11-03 00:22:37 CET LOG:  execute S_1: BEGIN
>         2007-11-03 00:22:37 CET LOG:  execute <unnamed>: insert into
>         USERS
>         (NAME) values ($1)
>         2007-11-03 00:22:37 CET DETAIL:  parameters: $1 = 'user'
>         2007-11-03 00:22:37 CET LOG:  execute S_2: COMMIT
>         2007-11-03 00:22:37 CET LOG:  execute S_1: BEGIN
>         2007-11-03 00:22:37 CET LOG:  execute <unnamed>: select
>         currval('USERS_id_seq')
>         2007-11-03 00:22:38 CET LOG:  execute S_2: COMMIT
>         2007-11-03 00:22:38 CET LOG:  execute S_1: BEGIN
>         2007-11-03 00:22:38 CET LOG:  execute <unnamed>: select
>         user0_.id as
>         id0_, user0_.NAME as NAME0_ from USERS user0_
>         2007-11-03 00:22:38 CET LOG:  execute S_2: COMMIT
>
>         In my own application which is doing 100 Hibernate queries in
>         a loop
>         (inside the same UserTransaction) the strange thing is that i
>         only have
>         an SQL transaction (BEGIN / COMMIT) arround the first query
>         and the 99
>         other are done outside any SQL transaction... Is there a way
>         to control
>         this or is this the right behaviour ? or maybe I don't
>         understand
>         something...
>
>         2007-11-02 19:43:04 CET LOG:  execute S_1: BEGIN
>         2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select
>         count(*) as y0_
>         from table this_ where this_.detecttime between $1 and $2
>         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-07-31
>         19:43:03.922+02', $2 = '2007-08-01 02:55:03.922+02'
>         2007-11-02 19:43:04 CET LOG:  execute S_2: COMMIT
>         2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select
>         count(*) as y0_
>         from table this_ where this_.detecttime between $1 and $2
>         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-01
>         02:55:03.922+02', $2 = '2007-08-01 10:07:03.922+02'
>         2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select
>         count(*) as y0_
>         from table this_ where this_.detecttime between $1 and $2
>         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-01
>         10:07:03.922+02', $2 = '2007-08-01 17:19:03.922+02'
>         2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select
>         count(*) as y0_
>         from table this_ where this_.detecttime between $1 and $2
>         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-01
>         17:19:03.922+02', $2 = '2007-08-02 00:31: 03.922+02'
>         2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select
>         count(*) as y0_
>         from table this_ where this_.detecttime between $1 and $2
>         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-02
>         00:31:03.922+02', $2 = '2007-08-02 07:43:03.922+02'
>         2007-11-02 19:43:04 CET LOG:  execute <unnamed>: select
>         count(*) as y0_
>         from table this_ where this_.detecttime between $1 and $2
>         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 = '2007-08-02
>         07:43:03.922+02', $2 = '2007-08-02 14:55:03.922+02'
>
>
>         Many thanks in advance !
>

>         Best regards.
>
>         Joël
>
>
>
>
>         ---------------------------------------------------------------------
>         To unsubscribe from this list, please visit:
>
>              http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Re:[btm-user] POM / 1PC

joël Winteregg-2
Hi Ludovic,

Thanks again for your support !
>
> There is one major difference between your code and the one in the
> Hibernate example: your code does 100 queries in 1 transaction while
> the example's does 1 query per transaction. This probably explains the
> differences (at least partly) you see in the Postgres logs.

Yes sure, my application is quite different from Hibernate example but
when i said that I just wanted to notice that my datasource and
Hibernate config was related to what I saw in this example...
>
> The fact that you see a begin/commit statement around only the first
> query still looks strange. I suspect your code to be responsible for
> this difference but could only confirm this if I had access to it.
> It might also be normal behavior of Postgres' JDBC driver. Maybe the
> logging logic is not precise enough or maybe the driver's a bit
> buggy.
>
Many many thanks for these inputs (I was able to solve my problem with
them)!!!! To be able to provide you a testing software of my processing
(queries, etc.) I changed the given example of Hibernate and I found out
that (in this case) my queries were all executed between a BEGIN and
COMMIT statement. The only difference was the DB driver version. I was
using the following version (dump from my POM file):
<dependency>
    <groupId>postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>8.2-504.jdbc3</version>
</dependency>

So I upgraded the jdbc driver of my project to version
postgresql-8.2-506.jdbc3.jar and everything is working as expected...


> At second look, I noticed this in your Hibernate config:
>
>  <property name="connection.pool_size">10</property>

Ahh yeah, thanks ! I forgot to remove it ;-)
>
> This is unneeded and confusing. Hibernate does not control the BTM
> datasource, it should only acquire it via JNDI. Now I wonder if that
> property is ignored or if it interferes somewhere. How did you
> configure the BTM PoolingDataSource ? How did you configure Hibernate
> to access it ? Could you try removing that connection.pool_size
> property and see if there is any difference ?
>
There is no difference. That was used for the built-in connection
pooling (when i was not using JNDI) !

For info, here is my PoolingDataSource config:

private static PoolingDataSource getDataSource() {          
  PoolingDataSource ds = new PoolingDataSource();
  ds.setUniqueName("jdbc/hibernate");
  ds.setClassName("org.postgresql.xa.PGXADataSource");
  ds.setMaxPoolSize(3);
  ds.getDriverProperties().put("databaseName", "hibernate");
  ds.getDriverProperties().put("user", "hibernate");
  ds.getDriverProperties().put("password", "hibernate");
  ds.getDriverProperties().put("serverName", "127.0.0.1");
  ds.getDriverProperties().put("portNumber", "5432");
  ds.init();
  return ds;
}
>
> About your question regarding SQL BEGIN/COMMIT, I don't really get it.
> What do you mean with UserTransaction that does not match scope ? The
> way it works is that any work done between begin() and commit() will
> be part of the same transaction, period. What do you find unclear ?

Yes my question was related to 1PC (only 1 DB is used) where I saw that
each SQL query is done between a BEGIN and COMMIT (as I have now in my
application), which doesn't match the scope of my defined
UserTransaction.begin() and UserTransaction.commit(). Here is an
example:

userTransaction.begin();
Session session = sf.getCurrentSession();
for(int i = 0; i <= nbTuples; i++){
  double nb = Double.valueOf(String.valueOf((Integer)
              session.createCriteria(User.class)
              .add(Restrictions.eq("name", "username "+i))
              .setProjection(Projections.rowCount())
              .uniqueResult()));
  System.out.println("User: usernaem "+i+" = "+nb);
}
userTransaction.commit();

With this given example (attached to this email), each SQL query related
to the criteria query execution is done between an SQL BEGIN and COMMIT.
I expected SQL transaction to reflect the one defined using
userTransaction.begin() and userTransaction.commit(). as follow:
BEGIN
 SELECT count() ....
 SELECT count() ....
 SELECT count() ....
 SELECT count() ....
COMMIT

Which behavior should be the right one ?

Many thanks and have a nice end of week-end !


Joël
 

> 2007/11/4, joël Winteregg <[hidden email]>:
>         Hi Ludovic,
>        
>         Many thanks for your answer ! Here is some more informations
>         about my
>         application:
>        
>         - All my implementation is based on the given example:
>         http://docs.codehaus.org/display/BTM/Hibernate
>        
>         - My datasource declaration is as follow:
>        
>         private static PoolingDataSource getDataSource_db1() {
>           PoolingDataSource ds = new PoolingDataSource();
>           ds.setUniqueName ("jdbc/hibernate");
>           ds.setClassName("org.postgresql.xa.PGXADataSource");
>           ds.setMaxPoolSize(3);
>           ds.getDriverProperties().put("databaseName", "hibernate");
>           ds.getDriverProperties ().put("user", "hibernate");
>           ds.getDriverProperties().put("password", "hibernate");
>           ds.getDriverProperties().put("serverName", "127.0.0.1");
>           ds.getDriverProperties().put("portNumber", "5432");
>           ds.init();
>           return ds;
>         }
>        
>         - My query look like this (pseudo-code):
>         0. UserTransaction.begin()
>         1. do 100 times
>         2.  sessionFactory.getCurrentSession()
>         3.  do the hibernate Criteria query
>         4. end do 100 times
>         5. UserTransaction.commit()
>        
>         - My hibernate config related to JTA is as follow:
>         <property name="current_session_context_class">jta</property>
>         <property
>         name="transaction.manager_lookup_class">BitronixTransactionManagerLookup</property>
>         <property
>         name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory </property>
>         <property
>         name="jta.UserTransaction">java:comp/UserTransaction</property>
>         <property name="connection.pool_size">10</property>
>        
>        
>         Any feedback would be appreciated !
>        
>         Regarding, SQL BEGIN/COMMIT using the given example
>         http://docs.codehaus.org/display/BTM/Hibernate is that right
>         that each
>         query should be done inside a BEGIN and COMMIT block, even if
>         the
>         UserTransaction doesn't match this scope (as explained in my
>         previous
>         email) ? Maybe I need some more reading about this, so do not
>         hesitate
>         to point me on some paper about this...
>        
>         Many thanks in advance.
>        
>         Regards,
>        
>        
>         Joël
>        
>         On Nov 3, 2007 3:15 PM , Ludovic Orban wrote:
>         > Hi Joël,
>         >
>         > I've asked Laco to post his POM file. I hope he'll do it
>         soon and that
>         > you'll find it useful. I'll jump on the occasion to get a
>         bit more
>         > familiar with maven as well and check what added value it
>         could bring
>         > to BTM.
>         >
>         > What you see in the pgsql logs can make sense. It depends on
>         basically
>         > every involved layer: the database itself, the JDBC driver,
>         BTM, the
>         > Hibernate config and your own code.
>         >
>         > It is nearly impossible to verify that you get consistent
>         results
>         > without being capable of reproducing the entire behavior of
>         your
>         > application. If you can make a downloadable archive with the
>         relevant
>         > parts of your application available somewhere I'll have a
>         look at it.
>         >
>         > Ludovic
>         >
>         > 2007/11/3, joël Winteregg <[hidden email] >:
>         >         Dear BTM users,
>         >
>         >
>         >         It's funny, because I discovered your Transaction
>         Manager
>         >         yesterday and
>         >         my both question were already partially asked during
>         this week
>         >         on this
>         >         mailing list ;-)
>         >
>         >         The first one was about Maven POM (I was looking for
>         a POM
>         >         file for
>         >         BTM). And the second one was about 1PC.
>         >         The good thing is that I learned that 1PC is
>         automatically
>         >         used when you
>         >         only have one DB (my case), but I'm not able to
>         understand the
>         >         behaviour
>         >         of SQL BEGIN and COMMIT within my UserTransaction.
>         >         I'm using BTM with postgresql 8.2 and Hibernate 3
>         (standalone
>         >         middleware) and when I look to my pgsql logs, BEGIN
>         and COMMIT
>         >         doesn't
>         >         match at all me UserTransaction.begin() and
>         >         UserTransaction.commit()
>         >         calls.
>         >
>         >         When I check my pgsql logs using the given example
>         >         (http://docs.codehaus.org/display/BTM/Hibernate)
>         every query
>         >         seems to be
>         >         done between a BEGIN and COMMIT (which does not
>         denote
>         >         UserTransaction
>         >         boundaries):
>         >
>         >         2007-11-03 00:22:36 CET LOG:  execute <unnamed>:
>         SELECT gid
>         >         FROM
>         >         pg_prepared_xacts
>         >         2007-11-03 00:22:37 CET LOG:  execute S_1: BEGIN
>         >         2007-11-03 00:22:37 CET LOG:  execute <unnamed>:
>         insert into
>         >         USERS
>         >         (NAME) values ($1)
>         >         2007-11-03 00:22:37 CET DETAIL:  parameters: $1 =
>         'user'
>         >         2007-11-03 00:22:37 CET LOG:  execute S_2: COMMIT
>         >         2007-11-03 00:22:37 CET LOG:  execute S_1: BEGIN
>         >         2007-11-03 00:22:37 CET LOG:  execute <unnamed>:
>         select
>         >         currval('USERS_id_seq')
>         >         2007-11-03 00:22:38 CET LOG:  execute S_2: COMMIT
>         >         2007-11-03 00:22:38 CET LOG:  execute S_1: BEGIN
>         >         2007-11-03 00:22:38 CET LOG:  execute <unnamed>:
>         select
>         >         user0_.id as
>         >         id0_, user0_.NAME as NAME0_ from USERS user0_
>         >         2007-11-03 00:22:38 CET LOG:  execute S_2: COMMIT
>         >
>         >         In my own application which is doing 100 Hibernate
>         queries in
>         >         a loop
>         >         (inside the same UserTransaction) the strange thing
>         is that i
>         >         only have
>         >         an SQL transaction (BEGIN / COMMIT) arround the
>         first query
>         >         and the 99
>         >         other are done outside any SQL transaction... Is
>         there a way
>         >         to control
>         >         this or is this the right behaviour ? or maybe I
>         don't
>         >         understand
>         >         something...
>         >
>         >         2007-11-02 19:43:04 CET LOG:  execute S_1: BEGIN
>         >         2007-11-02 19:43:04 CET LOG:  execute <unnamed>:
>         select
>         >         count(*) as y0_
>         >         from table this_ where this_.detecttime between $1
>         and $2
>         >         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 =
>         '2007-07-31
>         >         19:43:03.922+02', $2 = '2007-08-01 02:55:03.922+02'
>         >         2007-11-02 19:43:04 CET LOG:  execute S_2: COMMIT
>         >         2007-11-02 19:43:04 CET LOG:  execute <unnamed>:
>         select
>         >         count(*) as y0_
>         >         from table this_ where this_.detecttime between $1
>         and $2
>         >         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 =
>         '2007-08-01
>         >         02:55:03.922+02', $2 = '2007-08-01 10:07:03.922+02'
>         >         2007-11-02 19:43:04 CET LOG:  execute <unnamed>:
>         select
>         >         count(*) as y0_
>         >         from table this_ where this_.detecttime between $1
>         and $2
>         >         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 =
>         '2007-08-01
>         >         10:07:03.922+02', $2 = '2007-08-01 17:19:03.922+02'
>         >         2007-11-02 19:43:04 CET LOG:  execute <unnamed>:
>         select
>         >         count(*) as y0_
>         >         from table this_ where this_.detecttime between $1
>         and $2
>         >         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 =
>         '2007-08-01
>         >         17:19:03.922+02', $2 = '2007-08-02 00:31: 03.922+02'
>         >         2007-11-02 19:43:04 CET LOG:  execute <unnamed>:
>         select
>         >         count(*) as y0_
>         >         from table this_ where this_.detecttime between $1
>         and $2
>         >         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 =
>         '2007-08-02
>         >         00:31:03.922+02', $2 = '2007-08-02 07:43:03.922+02'
>         >         2007-11-02 19:43:04 CET LOG:  execute <unnamed>:
>         select
>         >         count(*) as y0_
>         >         from table this_ where this_.detecttime between $1
>         and $2
>         >         2007-11-02 19:43:04 CET DETAIL:  parameters: $1 =
>         '2007-08-02
>         >         07:43:03.922+02', $2 = '2007-08-02 14:55:03.922+02'
>         >
>         >
>         >         Many thanks in advance !
>         >
>         >         Best regards.
>         >
>         >         Joël
>         >
>         >
>         >
>         >
>         >
>         ---------------------------------------------------------------------
>         >         To unsubscribe from this list, please visit:
>         >
>         >              http://xircles.codehaus.org/manage_email
>         >
>         >
>         >
>        
>        
>         ---------------------------------------------------------------------
>         To unsubscribe from this list, please visit:
>        
>             http://xircles.codehaus.org/manage_email
>        
>        
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Test.java (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re:[btm-user] POM / 1PC

joël Winteregg-2
Hello Ludovic,

>
> I'm glad I could help.

Thanks again ;-)

>
> Regarding your last question, your logic is good. I would also expect
> this:
>
> BEGIN
>  SELECT count() ....
>  SELECT count() ....
>  SELECT count() ....
>  SELECT count() ....
> COMMIT

Ahh ok, cool ! So I still have a mistake with my driver... Or could it
be directly related to BTM ? (I should maybe read a bit more about this
XA protocol and JTA implementation, or where could I find more info
about this behaviour ? in XA protocol definition ?)
>
> I did not reproduce your app's behavior as I'm lacking time to do it
> so I cannot guarantee that your setup is working as expected. I'm not
> even sure Postgres's XA is usable or not. That will unfortunately be
> something you'll have to discover yourself.

Ok sure ! I will do a bit of testing I think ! I will let you (btm user
list) know about this...
>
> As a workaround, since you're only going to run 1PC transaction you
> could try using the Last Resource Commit and use Postgres in non-XA
> mode as described here:
> http://docs.codehaus.org/display/BTM/LastResourceCommit

> As long as you only use one database this will be 100% safe.
>
Ahh ok, cool ! So the JTA could work without using XA protocol (with 1PC
only). Is this an "home made" processing or is it a standard use of this
specificity ?

Many thanks & enjoy your Tuesday !

Regards,

Joël


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email