<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Strange behavior with multithreading in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68546#M43960</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Now I see… The nextId block stuff indeed gets a new connection (to have seperate transaction, to be sure id's aren't taken by others). So basically the current thread can't reuse the same connection for this (so it's actually holding a resource of another type).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is indeed an issue that was overlooked.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Apr 2011 09:07:08 GMT</pubDate>
    <dc:creator>frederikherema1</dc:creator>
    <dc:date>2011-04-14T09:07:08Z</dc:date>
    <item>
      <title>Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68539#M43953</link>
      <description>Hi,I am observing an undesired behavior with multithreaded use of Activiti.My program starts a number of threads, each of them starts a new business process. My business process is comprised of 4 Java Services, each of them just printing a message and sleeping for some time. (Service1, Service2a and</description>
      <pubDate>Wed, 13 Apr 2011 10:59:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68539#M43953</guid>
      <dc:creator>marcinj</dc:creator>
      <dc:date>2011-04-13T10:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68540#M43954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If&amp;nbsp; there are no "waitstates" in the process, the connection is indeed only returned after the process finished, so if the number of connections is limited, the behaviour you see is to be expected.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Apr 2011 17:49:51 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68540#M43954</guid>
      <dc:creator>ronald_van_kuij</dc:creator>
      <dc:date>2011-04-13T17:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68541#M43955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;maybe my previous post was not clear. This is not about the number of connections in the pool. Activiti (or Ibatis ?) seem to request the resources (db connections) in the following fashion:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(let's say there are 2 connections available)&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;Thread A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread B&lt;BR /&gt;getConnection -&amp;gt; OK!&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getConnection -&amp;gt; OK!&lt;BR /&gt;getConnection -&amp;gt; wait…&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getConnection -&amp;gt; wait…&lt;BR /&gt;…now both threads are just stuck forever…&lt;BR /&gt;&lt;/CODE&gt;&lt;SPAN&gt;And that's a classic deadlock example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my case, it is unclear for me what is the point of the second request ? Avoiding it would prevent the deadlock.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Marcin Jaskolski&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 05:27:30 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68541#M43955</guid>
      <dc:creator>marcinj</dc:creator>
      <dc:date>2011-04-14T05:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68542#M43956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;your original post was indeed not clear (enough) and your second post&amp;nbsp; makes it a little more clear. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you sure it is activiti requesting the second connection? In you log I do not see a second connection being retrieved before one s closed in the same thread.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Still then, the pool size has to be tuned for what fuynctionality wise is needed, even if activiti requests a second connection in a thread.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 07:15:52 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68542#M43956</guid>
      <dc:creator>ronald_van_kuij</dc:creator>
      <dc:date>2011-04-14T07:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68543#M43957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What if you change your pool with a datasource pooling solutiuon such as DBCP? The iBatis default connection pool is fairly simple implemented, last time I went through the code.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 08:12:49 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68543#M43957</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2011-04-14T08:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68544#M43958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The getConnection() on mybatis datasource always returns the same connection when transaction is active. The same goos for out spring-implementation (which used TransactionAwareDataSourceProxy), as long as spring-transaction is active&amp;nbsp; the getConnection() returns the same.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What datasource is your hackedDatasource actually extending?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 08:20:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68544#M43958</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2011-04-14T08:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68545#M43959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Ronald, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for your reply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please have a closer look at Thread-13. It asks for the second connection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is perfectly agreeable that &lt;/SPAN&gt;&lt;SPAN style="text-decoration: underline;"&gt;performance-wise&lt;/SPAN&gt;&lt;SPAN&gt; the pool size has to be tuned. But still, if the program &lt;/SPAN&gt;&lt;SPAN style="text-decoration: underline;"&gt;blocks&lt;/SPAN&gt;&lt;SPAN&gt;, it is a highly problematic situation. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(As a rule of thumb, process should not ask for an additional resource if it's already holding a resource of the same type.&amp;nbsp; :geek: )&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have run a few more tests and I have a more detailed information now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One of my threads enters the synchronized method: org.activiti.engine.impl.db.DbIdGenerator.getNextId(DbIdGenerator.java:34), and the call proceeds to the point where it asks for additional connection:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Thread-38" prio=6 tid=0x0000000006f14800 nid=0x10fc in Object.wait() [0x000000000a24c000]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; java.lang.Thread.State: WAITING (on object monitor)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; at java.lang.Object.wait(Native Method)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; - waiting on &amp;lt;0x00000000ee416210&amp;gt; (a org.apache.commons.pool.impl.GenericObjectPool$Latch)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; at java.lang.Object.wait(Object.java:485)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;STRONG&gt;at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1115)&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt; - locked &amp;lt;0x00000000ee416210&amp;gt; (a org.apache.commons.pool.impl.GenericObjectPool$Latch)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;…..&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; at org.activiti.engine.impl.db.DbIdGenerator.getNewBlock(DbIdGenerator.java:41)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; - locked &amp;lt;0x00000000ee4112b0&amp;gt; (a org.activiti.engine.impl.db.DbIdGenerator)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; at org.activiti.engine.impl.db.DbIdGenerator.getNextId(DbIdGenerator.java:34)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; - locked &amp;lt;0x00000000ee4112b0&amp;gt; (a org.activiti.engine.impl.db.DbIdGenerator)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; at org.activiti.engine.impl.history.handler.ActivityInstanceStartHandler.notify(ActivityInstanceStartHandler.java:39)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;…..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and waits for free resource (sorry, no free resources now, you have to wait)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the meantime, other threads try to enter the getNextId method (but sorry, it's taken by the previous thread).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe this is a real problem. I cannot assume that my database pool is unlimited.&amp;nbsp; :lol: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If it's of any use, I am more than willing to provide source code, thread dumps, etc (too long to post).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Marcin Jaskolski&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 08:54:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68545#M43959</guid>
      <dc:creator>marcinj</dc:creator>
      <dc:date>2011-04-14T08:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68546#M43960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Now I see… The nextId block stuff indeed gets a new connection (to have seperate transaction, to be sure id's aren't taken by others). So basically the current thread can't reuse the same connection for this (so it's actually holding a resource of another type).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is indeed an issue that was overlooked.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 09:07:08 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68546#M43960</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2011-04-14T09:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68547#M43961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;What if you change your pool with a datasource pooling solutiuon such as DBCP? The iBatis default connection pool is fairly simple implemented, last time I went through the code.&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;Hi jbarrez, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for your reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using the Apache Commons DBCP, mainly to monitor who's asking for connections, closing them, etc. It's configured this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; myDataSource = new org.apache.commons.dbcp.BasicDataSource();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; myDataSource.setDriverClassName("org.postgresql.Driver");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; myDataSource.setUrl("jdbc:smileytongue:ostgresql://127.0.0.1:54322/activiti");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; myDataSource.setUsername("activiti");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; myDataSource.setPassword("activiti");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; myDataSource.setMaxActive(maxConnectionNumber);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; myDataSource.setMinIdle(0);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; System.out.println("max Active: " + myDataSource.getMaxActive());&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; DataSource ds = new HackedDataSource(myDataSource);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .createStandaloneProcessEngineConfiguration()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .setDataSource(ds);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; processEngine = processEngineConfiguration.buildProcessEngine();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; System.out.println("processEngine created OK!");&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;The classes HackedConnection and HackedDataSource implement java.sql.Connection and javax.sql.DataSource respectively. :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;public class HackedConnection implements Connection {&lt;BR /&gt;&lt;BR /&gt; private Connection conn;&lt;BR /&gt;&lt;BR /&gt; public HackedConnection(Connection conn) {&lt;BR /&gt;&amp;nbsp; this.conn = conn;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; public void close() throws SQLException {&lt;BR /&gt;&amp;nbsp; String name = Thread.currentThread().getName();&lt;BR /&gt;&amp;nbsp; System.out.println("&amp;nbsp; –Connection.close called for thread " + name&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + ".");&lt;BR /&gt;&amp;nbsp; HackerDatabase.customerLeaves(name);&lt;BR /&gt;&amp;nbsp; conn.close();&lt;BR /&gt;&amp;nbsp; System.out.println("&amp;nbsp; –Connection.close finishes for thread " + name&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + ".");&lt;BR /&gt; }&lt;BR /&gt;..delegate methods…&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;public class HackedDataSource implements DataSource {&lt;BR /&gt;&lt;BR /&gt; private DataSource dataSource;&lt;BR /&gt; private TreeSet&amp;lt;String&amp;gt; customers;&lt;BR /&gt;&lt;BR /&gt; public HackedDataSource(DataSource dataSource) {&lt;BR /&gt;&amp;nbsp; this.dataSource = dataSource;&lt;BR /&gt;&amp;nbsp; this.customers = new TreeSet&amp;lt;String&amp;gt;();&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; public Connection getConnection() throws SQLException {&lt;BR /&gt;&amp;nbsp; String name = Thread.currentThread().getName();&lt;BR /&gt;&amp;nbsp; System.out.println("&amp;nbsp; –getConnection called for thread " + name + ".");&lt;BR /&gt;&amp;nbsp; synchronized (customers) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (!"main".equals(name)) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (customers.contains(name))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("&amp;nbsp; —-hey!");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; customers.add(name);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; HackerDatabase.customerAsking(name);&lt;BR /&gt;&amp;nbsp; Connection conn = dataSource.getConnection();&lt;BR /&gt;&amp;nbsp; HackerDatabase.customerServed(name);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; System.out.println("&amp;nbsp;&amp;nbsp; –getConnection finishes for thread " + name&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + ".");&lt;BR /&gt;&amp;nbsp; return new HackedConnection(conn);&lt;BR /&gt; }&lt;BR /&gt;…delegate methods…&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;HackerDatabase maintains sets of threads waiting for the connection and those holding a connection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Marcin Jaskolski&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 09:09:12 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68547#M43961</guid>
      <dc:creator>marcinj</dc:creator>
      <dc:date>2011-04-14T09:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68548#M43962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To summarize: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If no free connections in connection-pool are available, and a new block of ID's is requested, an SQL-connection is requested -&amp;gt; thread has to wait for available SQLConnections. Since this fetching is done in a syncronized block, all other theads that use the ID-generator are blocked. Since they are blocked, they can't return the SQL-connection they use to the pool -&amp;gt; locked untill the pools maxWaitTime expires and the waiting thread gets an exception on the getConnection().&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 09:19:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68548#M43962</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2011-04-14T09:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68549#M43963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;To summarize: &lt;BR /&gt;If no free connections in connection-pool are available, and a new block of ID's is requested, an SQL-connection is requested -&amp;gt; thread has to wait for available SQLConnections. Since this fetching is done in a syncronized block, all other theads that use the ID-generator are blocked. Since they are blocked, they can't return the SQL-connection they use to the pool -&amp;gt; locked untill the pools maxWaitTime expires and the waiting thread gets an exception on the getConnection().&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Frederik,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;happy to see we have understanding here.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But the basic problem is not about synchronized methods, (the pool has to employ some sort of internal synchronization anyway), but about the need to get the second resource of the same type (JDBC connection).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Marcin Jaskolski&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 09:38:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68549#M43963</guid>
      <dc:creator>marcinj</dc:creator>
      <dc:date>2011-04-14T09:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68550#M43964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We're talking about the same thing&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://connect.hyland.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&amp;nbsp; I mean the syncronized method on getNextId() -&amp;gt; which does the second call for an sqlConnection. So if the pool is empty, the thread is stuck in the getNextId() method, which is syncronized. All other treads can't enter and wait as wel, not releasing SQLconnection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 10:02:33 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68550#M43964</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2011-04-14T10:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68551#M43965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So you always need the max number of threads + 1 connections in your pool if I understand correctly…&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 11:23:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68551#M43965</guid>
      <dc:creator>ronald_van_kuij</dc:creator>
      <dc:date>2011-04-14T11:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68552#M43966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ronald, thats indeed the only workaround there is right now, if you really want to be sure this problem never occurs. We're looking into it &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://connect.hyland.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 13:00:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68552#M43966</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2011-04-14T13:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68553#M43967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;By the way: as described in (and much more interesting findings) &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=1523" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=1523&lt;/A&gt;&lt;SPAN&gt;, the blocksize is configurable:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;property name="idBlockSize" value="10000" /&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(didnt know that myself anymore).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Apr 2011 07:56:41 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68553#M43967</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2011-04-15T07:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68554#M43968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The workaround seems to work for me ! Thanks a lot!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Marcin Jaskolski&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Apr 2011 08:06:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68554#M43968</guid>
      <dc:creator>marcinj</dc:creator>
      <dc:date>2011-04-18T08:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior with multithreading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68555#M43969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've added a patch to the case.&amp;nbsp; Is there a volunteer to validate this patch in a real environment?&amp;nbsp; We would need some proof on a highly concurrent system and we don't have this kind of setup in our QA lab.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Without such confirmation we don't know yet for sure if we are able to include it.&amp;nbsp; So everyone interested in this issue, please check out the patch attached to &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://jira.codehaus.org/browse/ACT-789" rel="nofollow noopener noreferrer"&gt;http://jira.codehaus.org/browse/ACT-789&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any information that validates the fix and that gives us more confidence it doesn't break anything else, is really appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Apr 2011 15:40:05 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/strange-behavior-with-multithreading/m-p/68555#M43969</guid>
      <dc:creator>tombaeyens</dc:creator>
      <dc:date>2011-04-19T15:40:05Z</dc:date>
    </item>
  </channel>
</rss>

