You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Uwe Schindler (JIRA)" <ji...@apache.org> on 2009/09/02 17:54:32 UTC

[jira] Created: (LUCENE-1885) NativeFSLockFactory.makeLock(...).isLocked() does not work

NativeFSLockFactory.makeLock(...).isLocked() does not work
----------------------------------------------------------

                 Key: LUCENE-1885
                 URL: https://issues.apache.org/jira/browse/LUCENE-1885
             Project: Lucene - Java
          Issue Type: Bug
            Reporter: Uwe Schindler
            Priority: Blocker
             Fix For: 2.9


IndexWriter.isLocked() or IndexReader.isLocked() do not work with NativeFSLockFactory.

The problem is, that the method NativeFSLock.isLocked() just checks if the same lock instance was locked before (lock != null). If the LockFactory created a new lock instance, this always returns false, even if its locked.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1885) NativeFSLockFactory.makeLock(...).isLocked() does not work

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1885?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12750590#action_12750590 ] 

Michael McCandless commented on LUCENE-1885:
--------------------------------------------

Nice catch Uwe!

> NativeFSLockFactory.makeLock(...).isLocked() does not work
> ----------------------------------------------------------
>
>                 Key: LUCENE-1885
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1885
>             Project: Lucene - Java
>          Issue Type: Bug
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>            Priority: Blocker
>             Fix For: 2.9
>
>
> IndexWriter.isLocked() or IndexReader.isLocked() do not work with NativeFSLockFactory.
> The problem is, that the method NativeFSLock.isLocked() just checks if the same lock instance was locked before (lock != null). If the LockFactory created a new lock instance, this always returns false, even if its locked.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Assigned: (LUCENE-1885) NativeFSLockFactory.makeLock(...).isLocked() does not work

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1885?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Uwe Schindler reassigned LUCENE-1885:
-------------------------------------

    Assignee: Uwe Schindler

I will solve this together with LUCENE-1877.

To test, if lock is obtained, you have to try locking and release the lock after that (if the lock was obtained):

{code}
  public synchronized boolean isLocked() {
    // the test for is isLocked is not directly possible with native file locks:
    
    // if we have a lock instance in this class, it is for sure locked:
    if (lockExists()) return true;
    
    // else try to obtain and release (if was locked) the lock to test
    try {
      boolean obtained = obtain();
      if (obtained) release();
      return !obtained;
    } catch (IOException ioe) {
      return false;
    }    
  }
{code}

The method lockExists contains the same like isLocked contained before and is used instead to check if a local lock instance is available (as quick break-out).

There is no patch as it is included in my work for 1877 and hard to unwire.

> NativeFSLockFactory.makeLock(...).isLocked() does not work
> ----------------------------------------------------------
>
>                 Key: LUCENE-1885
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1885
>             Project: Lucene - Java
>          Issue Type: Bug
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>            Priority: Blocker
>             Fix For: 2.9
>
>
> IndexWriter.isLocked() or IndexReader.isLocked() do not work with NativeFSLockFactory.
> The problem is, that the method NativeFSLock.isLocked() just checks if the same lock instance was locked before (lock != null). If the LockFactory created a new lock instance, this always returns false, even if its locked.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1885) NativeFSLockFactory.makeLock(...).isLocked() does not work

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1885?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12750610#action_12750610 ] 

Uwe Schindler commented on LUCENE-1885:
---------------------------------------

Thanks!

It was not so hard. After changing the default lock factory, a lot of tests were failing because of this.

> NativeFSLockFactory.makeLock(...).isLocked() does not work
> ----------------------------------------------------------
>
>                 Key: LUCENE-1885
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1885
>             Project: Lucene - Java
>          Issue Type: Bug
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>            Priority: Blocker
>             Fix For: 2.9
>
>
> IndexWriter.isLocked() or IndexReader.isLocked() do not work with NativeFSLockFactory.
> The problem is, that the method NativeFSLock.isLocked() just checks if the same lock instance was locked before (lock != null). If the LockFactory created a new lock instance, this always returns false, even if its locked.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Resolved: (LUCENE-1885) NativeFSLockFactory.makeLock(...).isLocked() does not work

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1885?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Uwe Schindler resolved LUCENE-1885.
-----------------------------------

    Resolution: Fixed

Committed revision: 811157

> NativeFSLockFactory.makeLock(...).isLocked() does not work
> ----------------------------------------------------------
>
>                 Key: LUCENE-1885
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1885
>             Project: Lucene - Java
>          Issue Type: Bug
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>            Priority: Blocker
>             Fix For: 2.9
>
>
> IndexWriter.isLocked() or IndexReader.isLocked() do not work with NativeFSLockFactory.
> The problem is, that the method NativeFSLock.isLocked() just checks if the same lock instance was locked before (lock != null). If the LockFactory created a new lock instance, this always returns false, even if its locked.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1885) NativeFSLockFactory.makeLock(...).isLocked() does not work

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1885?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12750841#action_12750841 ] 

Uwe Schindler commented on LUCENE-1885:
---------------------------------------

The new patch in LUCENE-1877 changes the isLocked() method to shortcut, if no lock file is present. In this case, without a lockfile, it cannot be not locked. This prevent NativeFSLock for creating the lock short time without really using it.


> NativeFSLockFactory.makeLock(...).isLocked() does not work
> ----------------------------------------------------------
>
>                 Key: LUCENE-1885
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1885
>             Project: Lucene - Java
>          Issue Type: Bug
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>            Priority: Blocker
>             Fix For: 2.9
>
>
> IndexWriter.isLocked() or IndexReader.isLocked() do not work with NativeFSLockFactory.
> The problem is, that the method NativeFSLock.isLocked() just checks if the same lock instance was locked before (lock != null). If the LockFactory created a new lock instance, this always returns false, even if its locked.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org