[Mondrian] Deadlock issue

Matt Campbell mcampbell at pentaho.com
Fri Nov 8 11:16:02 EST 2013


There's a risk of deadlock in Mondrian in a particular scenario, and I'd love to hear if people have any thoughts or suggestions for how best to fix it.  Here's the issue.  As a simplification, assume we're dealing with a db connection pool that allows only 1 connection.

1)  Thread (a), managed by sqlExecutor, fires SqlStatement.execute().  SqlStatement.execute() retrieves the 1 connection, but has not yet registered its statement with the SegmentCacheIndex.

2)  The Actor thread (b) executes a LoadBatchCommand, which calls SqlStatement.execute() to determine cardinality as a part of .optimizePredicates().  Thread (b) blocks waiting on the connection held by (a).

3)  Thread (a) attempts to register a statement with the SegmentCacheIndex via a Command issued to the ACTOR thread (b).  Thread (a) blocks waiting on a response from (b).


Luc and I have brainstormed on this for awhile, but haven't come up with any satisfying solutions.  Some of the ideas we've considered have included
* make sure column cardinality is known before submitting the LoadBatchCommand.
* Find some way to move optimizePredicates() inside the SegmentLoadCommand such that it happens in a sqlExector thread, not the actor thread.
* Make the call to register the statement with the index non-blocking.  This introduces some risk of inconsistency (e.g. a statement could fail before it's even been registered).


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20131108/108984e9/attachment.html 


More information about the Mondrian mailing list