You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "adamb (JIRA)" <ib...@incubator.apache.org> on 2006/07/06 09:05:29 UTC
[jira] Created: (IBATIS-318) Transaction demarcated accross
multiple threads...
Transaction demarcated accross multiple threads...
--------------------------------------------------
Key: IBATIS-318
URL: http://issues.apache.org/jira/browse/IBATIS-318
Project: iBatis for Java
Type: Bug
Components: SQL Maps
Versions: 2.1.5
Reporter: adamb
We are using iBATIS in the following way:
send the server a message which will do a SqlMap.startTransaction()
...
some time later
...
send the server a message which will do a SqlMap.<some sql operation>
...
If we set:
Pool.MaximumActiveConnections=1
Then we hit problems if the thread that does operations on the SqlMap is different to the thread which started the transaction
because
SqlMapClientImpl.getLocalSqlMapSession()
stores the session in a Threadlocal so it finds no session and attempts to automatically create a new one, but since the max connections has been reached it fails.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Closed: (IBATIS-318) Transaction demarcated accross multiple
threads...
Posted by "Jeff Butler (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-318?page=all ]
Jeff Butler closed IBATIS-318:
------------------------------
Resolution: Invalid
This is working as designed. You cannot have a transaction that spans threads. If you want to do something like this you'll have to guarantee thread affinity. But I would suggest not doing this. You would have the same issue in many transaction managers - because most of them use a ThreadLocal.
> Transaction demarcated accross multiple threads...
> --------------------------------------------------
>
> Key: IBATIS-318
> URL: http://issues.apache.org/jira/browse/IBATIS-318
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.1.5
> Reporter: adamb
>
> We are using iBATIS in the following way:
> send the server a message which will do a SqlMap.startTransaction()
> ...
> some time later
> ...
> send the server a message which will do a SqlMap.<some sql operation>
> ...
> If we set:
> Pool.MaximumActiveConnections=1
> Then we hit problems if the thread that does operations on the SqlMap is different to the thread which started the transaction
> because
> SqlMapClientImpl.getLocalSqlMapSession()
> stores the session in a Threadlocal so it finds no session and attempts to automatically create a new one, but since the max connections has been reached it fails.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (IBATIS-318) Transaction demarcated accross
multiple threads...
Posted by "adamb (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-318?page=comments#action_12420455 ]
adamb commented on IBATIS-318:
------------------------------
Cheers.
We are using iBATIS as the implementation of an API that requires long running transactions (i.e. a server call is not an atomic action)...
This is within an automated conversion framework, so switching to atomic transactions is not an option for us. We want to keep our framework using iBATIS because we believe that it is ideal for any future work that gets done after the conversion, but it must be able to support both modes. Our other competing option is to create a JDBC implementation of the API.
> Transaction demarcated accross multiple threads...
> --------------------------------------------------
>
> Key: IBATIS-318
> URL: http://issues.apache.org/jira/browse/IBATIS-318
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.1.5
> Reporter: adamb
>
> We are using iBATIS in the following way:
> send the server a message which will do a SqlMap.startTransaction()
> ...
> some time later
> ...
> send the server a message which will do a SqlMap.<some sql operation>
> ...
> If we set:
> Pool.MaximumActiveConnections=1
> Then we hit problems if the thread that does operations on the SqlMap is different to the thread which started the transaction
> because
> SqlMapClientImpl.getLocalSqlMapSession()
> stores the session in a Threadlocal so it finds no session and attempts to automatically create a new one, but since the max connections has been reached it fails.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (IBATIS-318) Transaction demarcated accross
multiple threads...
Posted by "adamb (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-318?page=comments#action_12419597 ]
adamb commented on IBATIS-318:
------------------------------
It may be working as designed, but not as documented. The Documentation just says to make sure that you end all transactions that you start to avoid losing connections in the pool ...(and we are ensuring that)... however the documentation does not say that all transactions are required to be started executed and ended in the same thread...
> Transaction demarcated accross multiple threads...
> --------------------------------------------------
>
> Key: IBATIS-318
> URL: http://issues.apache.org/jira/browse/IBATIS-318
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.1.5
> Reporter: adamb
>
> We are using iBATIS in the following way:
> send the server a message which will do a SqlMap.startTransaction()
> ...
> some time later
> ...
> send the server a message which will do a SqlMap.<some sql operation>
> ...
> If we set:
> Pool.MaximumActiveConnections=1
> Then we hit problems if the thread that does operations on the SqlMap is different to the thread which started the transaction
> because
> SqlMapClientImpl.getLocalSqlMapSession()
> stores the session in a Threadlocal so it finds no session and attempts to automatically create a new one, but since the max connections has been reached it fails.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (IBATIS-318) Transaction demarcated accross
multiple threads...
Posted by "adamb (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-318?page=comments#action_12420428 ]
adamb commented on IBATIS-318:
------------------------------
We can get iBATIS to operate across threads by making the SqlMapClientImpl.getLocalSqlMapSession() protected instead of private, and then in a subclass override that method so that it gets the session from a static HashMap, based on a session key that is passed in to the constructor of the subclass.
This has stopped rogue connections from being autocreated.
> Transaction demarcated accross multiple threads...
> --------------------------------------------------
>
> Key: IBATIS-318
> URL: http://issues.apache.org/jira/browse/IBATIS-318
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.1.5
> Reporter: adamb
>
> We are using iBATIS in the following way:
> send the server a message which will do a SqlMap.startTransaction()
> ...
> some time later
> ...
> send the server a message which will do a SqlMap.<some sql operation>
> ...
> If we set:
> Pool.MaximumActiveConnections=1
> Then we hit problems if the thread that does operations on the SqlMap is different to the thread which started the transaction
> because
> SqlMapClientImpl.getLocalSqlMapSession()
> stores the session in a Threadlocal so it finds no session and attempts to automatically create a new one, but since the max connections has been reached it fails.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (IBATIS-318) Transaction demarcated accross
multiple threads...
Posted by "Jeff Butler (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-318?page=comments#action_12420440 ]
Jeff Butler commented on IBATIS-318:
------------------------------------
You'll be happy to know that we've made that method protected in the 2.2.0 release. However, we will continue to stress that this is an unsupported means of extending iBATIS and our implementation will be subject to change at any time.
I don't sense any will among the committers to allow transactions to span thread boundaries, so I think you'll always be "in the wild" on this one. What's more likely is that we'll fix IBATIS-320 so that you can have multiple open transactions in a thread. There is some semblance of an API for that.
I have recently updated the documentation with some further clarifications on this issue.
> Transaction demarcated accross multiple threads...
> --------------------------------------------------
>
> Key: IBATIS-318
> URL: http://issues.apache.org/jira/browse/IBATIS-318
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.1.5
> Reporter: adamb
>
> We are using iBATIS in the following way:
> send the server a message which will do a SqlMap.startTransaction()
> ...
> some time later
> ...
> send the server a message which will do a SqlMap.<some sql operation>
> ...
> If we set:
> Pool.MaximumActiveConnections=1
> Then we hit problems if the thread that does operations on the SqlMap is different to the thread which started the transaction
> because
> SqlMapClientImpl.getLocalSqlMapSession()
> stores the session in a Threadlocal so it finds no session and attempts to automatically create a new one, but since the max connections has been reached it fails.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira