You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by "Desimpel, Ignace" <Ig...@nuance.com> on 2018/01/10 10:34:01 UTC

Calling StorageService.loadNewSSTables function results in deadlock with compaction background task.

Tested on version 2.2.11 (but seems like trunck 3.x is still the same for the related code path), using nodetool refresh for restoring a snapshot

I guess the Cassandra committers can do something with this 😊.


Calling StorageService.loadNewSSTables function results in deadlock with compaction background task,

because  :


From StorageService class , function public void loadNewSSTables(String ksName, String cfName)

a call is made to ColumnFamilyStore class , function public static synchronized void loadNewSSTables(String ksName, String cfName)

and then a call to Keyspace class, function public static Keyspace open(String keyspaceName)

getting to the function private static Keyspace open(String keyspaceName, Schema schema, boolean loadSSTables)

finally trying to get a lock by synchronized (Keyspace.class)


So inside the ColumnFamilyStore class lock, there is an attempt to get the lock on the Keyspace.class


Now at the same time I have the thread OptionalTasks executing the ColumnFamilyStore.getBackgroundCompactionTaskSubmitter() task.

The thread task is also calling Keyspace.open function, already progressed as far as getting the lock on Keyspace class.

But then the call also initializes the column families and thus is calling on class ColumnFamilyStore the public static synchronized ColumnFamilyStore createColumnFamilyStore ...


So function 1 locks A and then B

And function 2 locks B and then A

leading to deadlock


Regards,

Ignace

Re: Calling StorageService.loadNewSSTables function results in deadlock with compaction background task.

Posted by Jeff Jirsa <jj...@gmail.com>.
Can you open a JIRA with this info? 

-- 
Jeff Jirsa


> On Jan 10, 2018, at 2:34 AM, Desimpel, Ignace <Ig...@nuance.com> wrote:
> 
> Tested on version 2.2.11 (but seems like trunck 3.x is still the same for the related code path), using nodetool refresh for restoring a snapshot
> I guess the Cassandra committers can do something with this 😊.
> 
> Calling StorageService.loadNewSSTables function results in deadlock with compaction background task, 
> because  : 
> 
> From StorageService class , function public void loadNewSSTables(String ksName, String cfName)
> a call is made to ColumnFamilyStore class , function public static synchronized void loadNewSSTables(String ksName, String cfName)
> and then a call to Keyspace class, function public static Keyspace open(String keyspaceName)
> getting to the function private static Keyspace open(String keyspaceName, Schema schema, boolean loadSSTables)
> finally trying to get a lock by synchronized (Keyspace.class)
> 
> So inside the ColumnFamilyStore class lock, there is an attempt to get the lock on the Keyspace.class
> 
> Now at the same time I have the thread OptionalTasks executing the ColumnFamilyStore.getBackgroundCompactionTaskSubmitter() task.
> The thread task is also calling Keyspace.open function, already progressed as far as getting the lock on Keyspace class.
> But then the call also initializes the column families and thus is calling on class ColumnFamilyStore the public static synchronized ColumnFamilyStore createColumnFamilyStore ...
> 
> So function 1 locks A and then B
> And function 2 locks B and then A
> leading to deadlock
> 
> Regards,
> Ignace
> <Stack1.txt>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@cassandra.apache.org
> For additional commands, e-mail: user-help@cassandra.apache.org