You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by loreii alpha <lo...@gmail.com> on 2009/05/27 10:47:51 UTC

worspace.move() deadlock

Hi all,
during concurrent workspace in cluster jackrabbit environment move i
get a deadlock, (moving different node from different source to the
same destination directory)

as soon as possible i'll provide a test case.

have you ever seen something of similar?

Cheers
Lore

Re: worspace.move() deadlock

Posted by loreii alpha <lo...@gmail.com>.
Hi Alex,

Follow my test snippet, as you can see no synchronization is done over
thread and if an exception is thrown is simply skipped.
If you run this test the repository stops to work. Probably i'm doing some
mistake, if it is please report to me.
I hope this could be useful.

Cheers
Lore

%<------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    @Override
    public void execute() {
        try{
            Repository repo = JRFactory.getRepository(); //utility class
4load the repo

            //create default directories
            {
                Session session = repo.login(new
SimpleCredentials("username", "password".toCharArray()));
                Node root = session.getRootNode();
                if(!root.hasNode("A"))
                    root.addNode("A","nt:folder");
                if(!root.hasNode("B"))
                    root.addNode("B","nt:folder");
                if(!root.hasNode("D"))
                    root.addNode("D","nt:folder");
                session.save();
            }

            //add some nodes
            Thread add1 = new Thread(new Adder(repo,"A"));
            Thread add2 = new Thread(new Adder(repo,"B"));
            add1.start();
            add2.start();
            add1.join();
            add2.join();

            Thread mov1 = new Thread(new Mover(repo,"A","D"));
            Thread mov2 = new Thread(new Mover(repo,"B","D"));

            mov1.start();
            mov2.start();
            mov1.join();
            mov2.join();
            System.out.print("done");
        }catch (Exception e) {
            // TODO: handle exception
        }

    }




    class Adder implements Runnable{
        Repository repository;
        String dest;
        public Adder(Repository repository,String dest) {
            this.repository=repository;
            this.dest=dest;
        }

        public void run() {
            Session session=null;

            Random r = new Random();
            try{
                session = repository.login(new SimpleCredentials("username",
"password".toCharArray()));
                Node root = session.getRootNode();
                Node destNode = root.getNode(dest);
                for(int i=0;i<100;i++){


                    destNode.addNode("A"+r.nextLong(),"nt:folder"); //folder
as example.....
                    session.save();
                }

            }catch (Exception e) {
                //skip
                e.printStackTrace();
            }finally{
                if(session!=null)
                    session.logout();
            }
        }


    }

    class Mover implements Runnable{
        Repository repository;
        String src;
        String dst;

        public Mover(Repository repository,String src, String dst) {
            this.repository=repository;
            this.dst=dst;
            this.src=src;
        }

        public void run() {
            Session session=null;


            try{

                session = repository.login(new SimpleCredentials("username",
"password".toCharArray()));

                Node root = session.getRootNode();
                Node srcNode = root.getNode(src);
                Node dstNode = root.getNode(dst);

                NodeIterator i = srcNode.getNodes();

                while (i.hasNext()){
                    Node c = i.nextNode();
                    try{
                    session.move(c.getPath(),
dstNode.getPath()+"/"+c.getName());
                    session.save();
                    }catch (Exception e) {
                        System.err.println("skip "+e.getMessage());

                    }
                }



            }catch (Exception e) {
                //skip
                e.printStackTrace();
            }finally{
                if(session!=null)
                    session.logout();
            }
        }


    }
%<------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
On Wed, Jun 3, 2009 at 3:00 PM, loreii alpha <lo...@gmail.com> wrote:

> I'm preparing the test case, in the mean time this is the stacktrace :
>
> Thread [DefaultQuartzScheduler_Worker-3] (Suspended)
>     Object.wait(long) line: not available [native method] [local variables
> unavailable]
>     WriterPreferenceReadWriteLock$ReaderLock(Object).wait() line: 485
> [local variables unavailable]
>     WriterPreferenceReadWriteLock$ReaderLock.acquire() line: not available
> [local variables unavailable]
>     DefaultISMLocking$ReadLockImpl.<init>(Sync) line: 78
>     DefaultISMLocking$ReadLockImpl.<init>(Sync, DefaultISMLocking$1) line:
> 72
>     DefaultISMLocking.acquireReadLock(ItemId) line: 40
>     SharedItemStateManager.acquireReadLock(ItemId) line: 1401
>     SharedItemStateManager.hasItemState(ItemId) line: 279
>     XAItemStateManager.hasItemState(ItemId) line: 288
>     SessionItemStateManager.hasItemState(ItemId) line: 206
>     CachingHierarchyManager(HierarchyManagerImpl).hasItemState(ItemId)
> line: 164
>     CachingHierarchyManager.nodeRemoved(NodeState, Path, NodeId) line:
> 725
>     CachingHierarchyManager.nodeRemoved(NodeState, Name, int, NodeId) line:
> 455
>     StateChangeDispatcher.notifyNodeRemoved(NodeState, Name, int, NodeId)
> line: 157
>     SessionItemStateManager.nodeRemoved(NodeState, Name, int, NodeId) line:
> 941
>     NodeState.notifyNodeRemoved(ChildNodeEntry) line: 871
>     NodeState.removeChildNodeEntry(Name, int) line: 388
>     XASessionImpl(SessionImpl).move(String, String) line: 1035
>     Worker.execute(JobExecutionContext) line: 121
>     Worker.run() line: 202
>     SimpleThreadPool$WorkerThread.run() line: 525
>
> Cheers
> Lore
>
>
> On Wed, May 27, 2009 at 2:20 PM, Alexander Klimetschek <ak...@day.com>wrote:
>
>> On Wed, May 27, 2009 at 10:47 AM, loreii alpha <lo...@gmail.com>
>> wrote:
>> > Hi all,
>> > during concurrent workspace in cluster jackrabbit environment move i
>> > get a deadlock, (moving different node from different source to the
>> > same destination directory)
>> >
>> > as soon as possible i'll provide a test case.
>> >
>> > have you ever seen something of similar?
>>
>> I couldn't find anything in the JIRA [1], so reporting a bug and
>> providing a test case would be good!
>>
>> [1]
>> http://issues.apache.org/jira/secure/QuickSearch.jspa?searchString=jcr+deadlock
>>
>> Regards,
>> Alex
>>
>> --
>> Alexander Klimetschek
>> alexander.klimetschek@day.com
>>
>
>

Re: worspace.move() deadlock

Posted by loreii alpha <lo...@gmail.com>.
I'm preparing the test case, in the mean time this is the stacktrace :

Thread [DefaultQuartzScheduler_Worker-3] (Suspended)
    Object.wait(long) line: not available [native method] [local variables
unavailable]
    WriterPreferenceReadWriteLock$ReaderLock(Object).wait() line: 485 [local
variables unavailable]
    WriterPreferenceReadWriteLock$ReaderLock.acquire() line: not available
[local variables unavailable]
    DefaultISMLocking$ReadLockImpl.<init>(Sync) line: 78
    DefaultISMLocking$ReadLockImpl.<init>(Sync, DefaultISMLocking$1) line:
72
    DefaultISMLocking.acquireReadLock(ItemId) line: 40
    SharedItemStateManager.acquireReadLock(ItemId) line: 1401
    SharedItemStateManager.hasItemState(ItemId) line: 279
    XAItemStateManager.hasItemState(ItemId) line: 288
    SessionItemStateManager.hasItemState(ItemId) line: 206
    CachingHierarchyManager(HierarchyManagerImpl).hasItemState(ItemId) line:
164
    CachingHierarchyManager.nodeRemoved(NodeState, Path, NodeId) line:
725
    CachingHierarchyManager.nodeRemoved(NodeState, Name, int, NodeId) line:
455
    StateChangeDispatcher.notifyNodeRemoved(NodeState, Name, int, NodeId)
line: 157
    SessionItemStateManager.nodeRemoved(NodeState, Name, int, NodeId) line:
941
    NodeState.notifyNodeRemoved(ChildNodeEntry) line: 871
    NodeState.removeChildNodeEntry(Name, int) line: 388
    XASessionImpl(SessionImpl).move(String, String) line: 1035
    Worker.execute(JobExecutionContext) line: 121
    Worker.run() line: 202
    SimpleThreadPool$WorkerThread.run() line: 525

Cheers
Lore

On Wed, May 27, 2009 at 2:20 PM, Alexander Klimetschek <ak...@day.com>wrote:

> On Wed, May 27, 2009 at 10:47 AM, loreii alpha <lo...@gmail.com>
> wrote:
> > Hi all,
> > during concurrent workspace in cluster jackrabbit environment move i
> > get a deadlock, (moving different node from different source to the
> > same destination directory)
> >
> > as soon as possible i'll provide a test case.
> >
> > have you ever seen something of similar?
>
> I couldn't find anything in the JIRA [1], so reporting a bug and
> providing a test case would be good!
>
> [1]
> http://issues.apache.org/jira/secure/QuickSearch.jspa?searchString=jcr+deadlock
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>

Re: worspace.move() deadlock

Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, May 27, 2009 at 10:47 AM, loreii alpha <lo...@gmail.com> wrote:
> Hi all,
> during concurrent workspace in cluster jackrabbit environment move i
> get a deadlock, (moving different node from different source to the
> same destination directory)
>
> as soon as possible i'll provide a test case.
>
> have you ever seen something of similar?

I couldn't find anything in the JIRA [1], so reporting a bug and
providing a test case would be good!

[1] http://issues.apache.org/jira/secure/QuickSearch.jspa?searchString=jcr+deadlock

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com