[
https://issues.apache.org/jira/browse/DERBY-6110?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13930316#comment-13930316
]
Knut Anders Hatlen commented on DERBY-6110:
-------------------------------------------
I'm not sure if this is a bug.
I see that EmbedXAResource.end() nulls out the physical connection without
closing the logical connection. And, indeed, calling isClosed() on the logical
connection after ending the transaction branch, makes it go through the code
path in the above stack trace and open a new physical connection, and the
isClosed() method returns false. I believe that at least in this case it is
correct to return false from isClosed(). I base that on the following paragraph
in the JDBC 4.1 specification, section 12.4 Transaction Management:
{quote}
Participation in a distributed transaction is defined as the work done between
invocations of the methods XAResource.start and XAResource.end. Outside
these boundaries, the transaction mode is local, and a connection behaves
exactly
like a local connection.
{quote}
This suggests that the connection should work after the transaction branch has
been ended, and that it is correct to leave the logical connection open.
I think we could close this issue as not a bug for now. If we find a case where
the reopening of the physical connection causes a problem, we could revisit it.
> BrokeredConnection.isClosed() may open a new connection
> -------------------------------------------------------
>
> Key: DERBY-6110
> URL: https://issues.apache.org/jira/browse/DERBY-6110
> Project: Derby
> Issue Type: Bug
> Components: JDBC
> Affects Versions: 10.8.2.2
> Reporter: Knut Anders Hatlen
> Labels: derby_triage10_11
>
> I noticed this odd-looking stack trace in the thread dump provided in
> DERBY-5632:
> "DRDAConnThread_22" prio=3 tid=0x0000000101b81800 nid=0x31 waiting for
> monitor entry [0xfffffffd236fe000]
> java.lang.Thread.State: BLOCKED (on object monitor)
> at
> org.apache.derby.impl.store.access.RAMAccessManager.conglomCacheFind(Unknown
> Source)
> - waiting to lock <0xfffffffd3a7fcc68> (a
> org.apache.derby.impl.services.cache.ConcurrentCache)
> at
> org.apache.derby.impl.store.access.RAMTransaction.findExistingConglomerate(Unknown
> Source)
> at
> org.apache.derby.impl.store.access.RAMTransaction.openConglomerate(Unknown
> Source)
> at
> org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getDescriptorViaIndexMinion(Unknown
> Source)
> at
> org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getDescriptorViaIndex(Unknown
> Source)
> at
> org.apache.derby.impl.sql.catalog.DataDictionaryImpl.locateSchemaRow(Unknown
> Source)
> at
> org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSchemaDescriptor(Unknown
> Source)
> at
> org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.initDefaultSchemaDescriptor(Unknown
> Source)
> at
> org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.initialize(Unknown
> Source)
> at org.apache.derby.impl.db.BasicDatabase.setupConnection(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.TransactionResourceImpl.startTransaction(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.EmbedConnection.checkUserIsNotARole(Unknown Source)
> at
> org.apache.derby.impl.jdbc.EmbedConnection.checkUserCredentials(Unknown
> Source)
> at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
> at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown Source)
> at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown Source)
> at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
> at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
> at org.apache.derby.jdbc.EmbeddedDataSource.getConnection(Unknown
> Source)
> at
> org.apache.derby.jdbc.EmbedPooledConnection.openRealConnection(Unknown Source)
> at org.apache.derby.jdbc.EmbedXAConnection.getRealConnection(Unknown
> Source)
> at
> org.apache.derby.iapi.jdbc.BrokeredConnection.getRealConnection(Unknown
> Source)
> at org.apache.derby.iapi.jdbc.BrokeredConnection.isClosed(Unknown
> Source)
> at
> org.apache.derby.impl.drda.PiggyBackedSessionData.getInstance(Unknown Source)
> at
> org.apache.derby.impl.drda.Database.getPiggyBackedSessionData(Unknown Source)
> at org.apache.derby.impl.drda.DRDAConnThread.writePBSD(Unknown Source)
> at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown
> Source)
> at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
> It looks as if BrokeredConnection.isClosed() fails to find a usable physical
> connection and then tries to open a new one. Presumably, when this happens,
> isClosed() will return false. It sounds more reasonable to return true in
> such circumstances.
--
This message was sent by Atlassian JIRA
(v6.2#6252)