<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>
<div>
<div>Thanks for pointing that out, Jon. &nbsp;Mikhail added your null pointer check with this PR: &nbsp;<a href="https://github.com/pentaho/mondrian/pull/719">https://github.com/pentaho/mondrian/pull/719</a></div>
<div><br>
</div>
<div>
<div id="MAC_OUTLOOK_SIGNATURE"></div>
</div>
</div>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:12pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>&lt;<a href="mailto:mondrian-bounces@pentaho.org">mondrian-bounces@pentaho.org</a>&gt; on behalf of Jonathan Rand &lt;<a href="mailto:rand.jc@gmail.com">rand.jc@gmail.com</a>&gt;<br>
<span style="font-weight:bold">Reply-To: </span>Mondrian list &lt;<a href="mailto:mondrian@pentaho.org">mondrian@pentaho.org</a>&gt;<br>
<span style="font-weight:bold">Date: </span>Tuesday, June 28, 2016 at 1:39 PM<br>
<span style="font-weight:bold">To: </span>Mondrian list &lt;<a href="mailto:mondrian@pentaho.org">mondrian@pentaho.org</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>Re: [Mondrian] hanging application: segment cache manager and schema load?<br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">I see that MONDRIAN-2476 has been marked resolved with this commit:&nbsp;<a href="https://github.com/pentaho/mondrian/pull/717/files">https://github.com/pentaho/mondrian/pull/717/files</a>. There's a problem with that fix - a null pointer guard in
 the clear() method that was deleted should have been kept to ensure that null values aren't inserted into the list.
<div>
<div><br>
</div>
<div>The change should be updated from this – &nbsp;</div>
<div><br>
</div>
<div>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RolapSchema schema = ref.get();</div>
<div>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (schema != null) {</div>
<div>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;schema.finalCleanUp();</div>
<div>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div>
<div>&#43; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;schemas.add(ref.get());</div>
<div><br>
</div>
<div>To this –</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RolapSchema schema = ref.get();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (schema != null) {</div>
<div>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;schema.finalCleanUp();</div>
<div>&#43; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;schemas.add(schema);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
</div>
<div><br>
</div>
<div>Full disclosure: I'm the developer that sent the proposed change to Jeff Wright in the first place, so this was my own mistake.</div>
<div><br>
</div>
<div>Jon Rand</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Jun 14, 2016 at 10:35 AM, Wright, Jeff <span dir="ltr">
&lt;<a href="mailto:jeff.s.wright@truvenhealth.com" target="_blank">jeff.s.wright@truvenhealth.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">Regarding MONDRIAN-2476 deadlock, we were able to reproduce the deadlock in development with Mondrian 3.12.0.1-196. There’s a thread dump excerpt below.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">The engineer working on this with me has a code change he’s going to try locally. Here’s his description (this description is based on the older, synchronized
 RolapSchemaPool, but he’s actually testing a modified version with the reentrant lock, so just translate the “synchronized” comments to “lock”):<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">The deadlock problem in RolapSchemaPool seems to be related to calling schema.finalCleanUp() while holding the write lock. I’ve made the following changes:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><span>1.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><u></u><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">The first change is to make the public remove() methods unsynchronized, relying instead on synchronization of lower-level methods, as described next.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><span>2.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><u></u><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">The second change is to refactor the private remove() method, separating the functionality that needs to be in a critical section (removing the schema
 from the mapKeyToSchema and mapMd5ToSchema maps) from the functionality that calls the schema.finalCleanup() method.&nbsp; The new method that removes the schema from the maps, removeFromSchemaMaps(), IS synchronized.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><span>3.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><u></u><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">The private remove() method is NOT synchronized.&nbsp; This method is still where the call to schema.finalCleanUp() is made, but schema.finalCleanUp() is called
 after the synchronized removeFromSchemaMaps() method has returned.&nbsp; This ensures that schema.finalCleanUp() will no longer be running inside the critical section and should no longer cause a deadlock.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><span>4.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><u></u><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">The same refactoring was applied to the RolapSchemaPool.clear() method.<u></u><u></u></span></p>
<p><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">Any reactions to that approach?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">Thread dump excerpt:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:8.0pt;font-family:Consolas">Name: mondrian.rolap.agg.SegmentCacheManager$ACTOR<u></u><u></u></span></b></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas;background:yellow">State: WAITING on
<a href="mailto:java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync@1bad7c39" target="_blank">
java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync@1bad7c39</a> owned by: mondrian.server.DynamicContentFinder$timer</span><span style="font-size:8.0pt;font-family:Consolas"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">Total blocked: 0&nbsp; Total waited: 290<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">Stack trace:
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">sun.misc.Unsafe.park(Native Method)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireShared(AbstractQueuedSynchronizer.java:964)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireShared(AbstractQueuedSynchronizer.java:1282)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock.lock(ReentrantReadWriteLock.java:731)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.RolapSchemaPool.getRolapSchemas(RolapSchemaPool.java:513) –
<span style="background:yellow">attempting to acquire lock.readLock</span><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.RolapSchema.getRolapSchemas(RolapSchema.java:990)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.agg.SegmentCacheManager.getStar(SegmentCacheManager.java:1592)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.agg.SegmentCacheManager$Handler.visit(SegmentCacheManager.java:634)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.agg.SegmentCacheManager$ExternalSegmentCreatedEvent.acceptWithoutResponse(SegmentCacheManager.java:1195)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.agg.SegmentCacheManager$Actor.run(SegmentCacheManager.java:992)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">java.lang.Thread.run(Thread.java:744)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:8.0pt;font-family:Consolas">Name: mondrian.server.<span style="background:yellow">DynamicContentFinder$timer</span><u></u><u></u></span></b></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">State: WAITING on
<a href="mailto:java.util.concurrent.CountDownLatch$Sync@330e0060" target="_blank">
java.util.concurrent.CountDownLatch$Sync@330e0060</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">Total blocked: 8&nbsp; Total waited: 327<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">Stack trace:
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">sun.misc.Unsafe.park(Native Method)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:994)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1303)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">java.util.concurrent.CountDownLatch.await(CountDownLatch.java:236)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.util.SlotFuture.get(SlotFuture.java:87)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.olap.Util.safeGet(Util.java:2101)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.util.BlockingHashMap.get(BlockingHashMap.java:63)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.agg.SegmentCacheManager$Actor.execute(SegmentCacheManager.java:1017)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.agg.SegmentCacheManager.execute(SegmentCacheManager.java:313)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.agg.AggregationManager$1.flushNonUnion(AggregationManager.java:129)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.CacheControlImpl.flushInternal(CacheControlImpl.java:204)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.CacheControlImpl.access$000(CacheControlImpl.java:36)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.CacheControlImpl$1.execute(CacheControlImpl.java:179)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.CacheControlImpl$1.execute(CacheControlImpl.java:177)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.server.Locus.execute(Locus.java:86)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.server.Locus.execute(Locus.java:71)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.CacheControlImpl.flush(CacheControlImpl.java:174)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.agg.AggregationManager$1.flush(AggregationManager.java:152)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.RolapSchema.flushSegments(RolapSchema.java:340)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.RolapSchema.finalCleanUp(RolapSchema.java:362)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.RolapSchemaPool.remove(RolapSchemaPool.java:474) –
<span style="background:yellow">has acquired lock.writeLock at this point</span><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.RolapSchemaPool.remove(RolapSchemaPool.java:462)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.rolap.CacheControlImpl.flushSchema(CacheControlImpl.java:300)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.server.DynamicContentFinder.flushCatalog(DynamicContentFinder.java:184)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.server.DynamicContentFinder.flushObsoleteCatalogs(DynamicContentFinder.java:175)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">&nbsp;&nbsp; - locked
<a href="mailto:com.truven.mondrian.server.DbContentFinder@58801091" target="_blank">
com.truven.mondrian.server.DbContentFinder@58801091</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.server.DynamicContentFinder.reloadDataSources(DynamicContentFinder.java:103)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">&nbsp;&nbsp; - locked
<a href="mailto:com.truven.mondrian.server.DbContentFinder@58801091" target="_blank">
com.truven.mondrian.server.DbContentFinder@58801091</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">mondrian.server.DynamicContentFinder$1.run(DynamicContentFinder.java:73)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">java.util.TimerThread.mainLoop(Timer.java:555)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">java.util.TimerThread.run(Timer.java:505)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">--jeff<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><a href="mailto:mondrian-bounces@pentaho.org" target="_blank">mondrian-bounces@pentaho.org</a>
 [mailto:<a href="mailto:mondrian-bounces@pentaho.org" target="_blank">mondrian-bounces@pentaho.org</a>]
<b>On Behalf Of </b>Wright, Jeff<br>
<b>Sent:</b> Thursday, March 31, 2016 8:57 AM<br>
<b>To:</b> Mondrian developer mailing list &lt;<a href="mailto:mondrian@pentaho.org" target="_blank">mondrian@pentaho.org</a>&gt;<br>
<b>Subject:</b> Re: [Mondrian] hanging application: segment cache manager and schema load?<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><a href="http://jira.pentaho.com/browse/MONDRIAN-2476" target="_blank">http://jira.pentaho.com/browse/MONDRIAN-2476</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">Thanks Luc! Based on your pointers, my interpretation is the deadlock can occur when:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><span>-<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><u></u><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">DynamicContentFinder is running (too bad I misspelled that in the JIRA title)<u></u><u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><span>-<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><u></u><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">A distributed cache is in place<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">The environment where this occurred has about 50 catalogs loaded.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">--jeff<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><a href="mailto:mondrian-bounces@pentaho.org" target="_blank">mondrian-bounces@pentaho.org</a>
 [<a href="mailto:mondrian-bounces@pentaho.org" target="_blank">mailto:mondrian-bounces@pentaho.org</a>]
<b>On Behalf Of </b>Luc Boudreau<br>
<b>Sent:</b> Wednesday, March 30, 2016 11:46 AM<br>
<b>To:</b> Mondrian developer mailing list &lt;<a href="mailto:mondrian@pentaho.org" target="_blank">mondrian@pentaho.org</a>&gt;<br>
<b>Subject:</b> Re: [Mondrian] hanging application: segment cache manager and schema load?<u></u><u></u></span></p>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
<div>
<p class="MsoNormal">Thanks for the file. Looking at it, I've found several threads waitin on lock 0x00000005e23c2028. Do a search for this value and you'll find them.<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
<div>
<p class="MsoNormal">Looking at other threads, I can also tell that the system was in the middle of a flush operation. Thread 0x00007f1b34146000 is currently flushing obsolete catalogs. This same thread owns the lock on the schema pool. It's a deadlock.&nbsp;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
<div>
<p class="MsoNormal">&nbsp;- Thread A tries to clear the cache of some elements. It first acquires a lock on the schema pool.&nbsp;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">&nbsp;- Thread A then sends a message to the Actor to do the actual flush, so it waits for an answer.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">&nbsp;- Thread B, the Actor, in the meanwhile, receives an external event. To process it, it needs a lock on the pool.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
<div>
<p class="MsoNormal">That's unfortunate timing. We'll need to think about how to fix this correctly. Please file a Jira bug with as much information as you can. If you can share some of the thread snippets, that's also useful to confirm our tests.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
<div>
<p class="MsoNormal">On Wed, Mar 30, 2016 at 11:27 AM, Luc Boudreau &lt;<a href="mailto:lucboudreau@gmail.com" target="_blank">lucboudreau@gmail.com</a>&gt; wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
<p class="MsoNormal">Your description is exact.&nbsp;<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
<div>
<p class="MsoNormal">I'm a little surprised that no other threads are waiting on that lock. Would you mind sharing the full thread dump? Maybe privately?<u></u><u></u></p>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
<div>
<p class="MsoNormal">On Wed, Mar 30, 2016 at 11:21 AM, Wright, Jeff &lt;<a href="mailto:jeff.s.wright@truvenhealth.com" target="_blank">jeff.s.wright@truvenhealth.com</a>&gt; wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">There are no other threads waiting on the same monitor. I have 5 thread dumps from 5 different app servers, and all of them have this same pattern. There are
 two Actor threads, one of the Actor threads is blocked on getRolapSchemas() and no other thread references the same monitor.
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">&nbsp;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">From your description, here’s how I imagine things to work with a 5 node cluster and a distributed cache... If a user runs MDX against CatalogA on Node1, the
 results of that query will get added to the distributed segment cache on Node1. The distributed cache will send an event to Nodes 2-5. That event will allow Nodes 2-5 to index the new segments. Indexing will force CatalogA to be loaded on Nodes 2-5, if it’s
 not already loaded. Is that right?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">&nbsp;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">--jeff</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">&nbsp;</span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><a href="mailto:mondrian-bounces@pentaho.org" target="_blank">mondrian-bounces@pentaho.org</a>
 [mailto:<a href="mailto:mondrian-bounces@pentaho.org" target="_blank">mondrian-bounces@pentaho.org</a>]
<b>On Behalf Of </b>Luc Boudreau<br>
<b>Sent:</b> Wednesday, March 30, 2016 10:34 AM<br>
<b>To:</b> Mondrian developer mailing list &lt;<a href="mailto:mondrian@pentaho.org" target="_blank">mondrian@pentaho.org</a>&gt;<br>
<b>Subject:</b> Re: [Mondrian] hanging application: segment cache manager and schema load?</span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">&nbsp;<u></u><u></u></p>
<div>
<p class="MsoNormal">This stack tells us that the Actor has received a notification from an external event. A new segment must be indexed. The Actor is waiting on the RolapSchemaPool to free up so that it can grap a Star instance and pin the segment.<u></u><u></u></p>
<div>
<p class="MsoNormal">&nbsp;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">What other threads are waiting on that same monitor? (<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">0x00007f1ad965f000)</span><u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal">&nbsp;<u></u><u></u></p>
<div>
<p class="MsoNormal">On Wed, Mar 30, 2016 at 9:14 AM, Wright, Jeff &lt;<a href="mailto:jeff.s.wright@truvenhealth.com" target="_blank">jeff.s.wright@truvenhealth.com</a>&gt; wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal">We’ve seen our application hang a couple times. Looking at thread dumps, I’m suspicious of this excerpt:<u></u><u></u></p>
<p class="MsoNormal">&nbsp;<u></u><u></u></p>
<p class="MsoNormal">&quot;mondrian.rolap.agg.SegmentCacheManager$ACTOR&quot; daemon prio=10 tid=0x00007f1b34170000 nid=0xf25 waiting for monitor entry [0x00007f1ad965f000]<u></u><u></u></p>
<p class="MsoNormal">&nbsp;&nbsp; java.lang.Thread.State: BLOCKED (on object monitor)<u></u><u></u></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at mondrian.rolap.RolapSchemaPool.getRolapSchemas(RolapSchemaPool.java:420)<u></u><u></u></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - waiting to lock &lt;0x00000005e23c2028&gt; (a mondrian.rolap.RolapSchemaPool)<u></u><u></u></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at mondrian.rolap.RolapSchema.getRolapSchemas(RolapSchema.java:930)<u></u><u></u></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at mondrian.rolap.agg.SegmentCacheManager.getStar(SegmentCacheManager.java:1621)<u></u><u></u></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at mondrian.rolap.agg.SegmentCacheManager$Handler.visit(SegmentCacheManager.java:661)<u></u><u></u></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at mondrian.rolap.agg.SegmentCacheManager$ExternalSegmentCreatedEvent.acceptWithoutResponse(SegmentCacheManager.java:1222)<u></u><u></u></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at mondrian.rolap.agg.SegmentCacheManager$Actor.run(SegmentCacheManager.java:1019)<u></u><u></u></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.Thread.run(Thread.java:724)<u></u><u></u></p>
<p class="MsoNormal">&nbsp;<u></u><u></u></p>
<p class="MsoNormal">I don’t fully understand SegmentCacheManager, but based on Julian’s 2012 blog post I get the impression the Actor thread is supposed to run very. If that corresponds to the stack trace above, that’s a big problem - we see schema loads take
 minutes.<u></u><u></u></p>
<p class="MsoNormal">&nbsp;<u></u><u></u></p>
<p class="MsoNormal">I also see that there were some code changes in August last year for MONDRIAN-2390, to make locking for schema load lower level. We don’t have that code.<u></u><u></u></p>
<p class="MsoNormal">&nbsp;<u></u><u></u></p>
<p class="MsoNormal">Btw we have a distributed cache.<u></u><u></u></p>
<p class="MsoNormal">&nbsp;<u></u><u></u></p>
<p class="MsoNormal">Does it sound like I’m on to a problem in our environment? Maybe even a general problem?<u></u><u></u></p>
<p class="MsoNormal"><span style="color:#888888">&nbsp;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#888888">--Jeff Wright</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
Mondrian mailing list<br>
<a href="mailto:Mondrian@pentaho.org" target="_blank">Mondrian@pentaho.org</a><br>
<a href="http://lists.pentaho.org/mailman/listinfo/mondrian" target="_blank">http://lists.pentaho.org/mailman/listinfo/mondrian</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal">&nbsp;<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
Mondrian mailing list<br>
<a href="mailto:Mondrian@pentaho.org" target="_blank">Mondrian@pentaho.org</a><br>
<a href="http://lists.pentaho.org/mailman/listinfo/mondrian" target="_blank">http://lists.pentaho.org/mailman/listinfo/mondrian</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
</div>
</div>
<br>
_______________________________________________<br>
Mondrian mailing list<br>
<a href="mailto:Mondrian@pentaho.org">Mondrian@pentaho.org</a><br>
<a href="http://lists.pentaho.org/mailman/listinfo/mondrian" rel="noreferrer" target="_blank">http://lists.pentaho.org/mailman/listinfo/mondrian</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</span>
</body>
</html>