[jira] Created: (LUCENE-715) IndexWriter does not release its write lock when trying to open an index which does not yet exist

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (LUCENE-715) IndexWriter does not release its write lock when trying to open an index which does not yet exist

JIRA jira@apache.org
IndexWriter does not release its write lock when trying to open an index which does not yet exist
-------------------------------------------------------------------------------------------------

                 Key: LUCENE-715
                 URL: http://issues.apache.org/jira/browse/LUCENE-715
             Project: Lucene - Java
          Issue Type: Bug
          Components: Index
    Affects Versions: 2.0.0
         Environment: Windows XP, Java 1.5, IntelliJ 6
            Reporter: Matthew Bogosian


In version 2.0.0, the private IndexWriter constructor does not properly remove its write lock in the event of an error. This can be seen when one attempts to open (not create) an index in a directory which exists, but in which there is no segments file. Here is the offending code:

    247   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
    248     throws IOException {
    249       this.closeDir = closeDir;
    250       directory = d;
    251       analyzer = a;
    252
    253       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
    254       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
    255         throw new IOException("Index locked for write: " + writeLock);
    256       this.writeLock = writeLock;                   // save it
    257
    258       synchronized (directory) {        // in- & inter-process sync
    259         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
    260             public Object doBody() throws IOException {
    261               if (create)
    262                 segmentInfos.write(directory);
    263               else
    264                 segmentInfos.read(directory);
    265               return null;
    266             }
    267           }.run();
    268       }
    269   }

On line 254, a write lock is obtained by the constructor. If an exception is raised inside the doBody() method (on line 260), then that exception is propagated, the constructor will fail, but the lock is not released until the object is garbage collected. This is typically an issue except when using the IndexModifier class.

As of the filing of this bug, this has not yet been fixed in the trunk (IndexWriter.java#472959):

    251   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
    252     throws IOException {
    253       this.closeDir = closeDir;
    254       directory = d;
    255       analyzer = a;
    256
    257       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
    258       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
    259         throw new IOException("Index locked for write: " + writeLock);
    260       this.writeLock = writeLock;                   // save it
    261
    262       synchronized (directory) {        // in- & inter-process sync
    263         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
    264             public Object doBody() throws IOException {
    265               if (create)
    266                 segmentInfos.write(directory);
    267               else
    268                 segmentInfos.read(directory);
    269               return null;
    270             }
    271           }.run();
    272       }
    273   }

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (LUCENE-715) IndexWriter does not release its write lock when trying to open an index which does not yet exist

JIRA jira@apache.org
     [ http://issues.apache.org/jira/browse/LUCENE-715?page=all ]

Matthew Bogosian updated LUCENE-715:
------------------------------------

    Attachment: LUCENE-715.patch

Attaching the fix as a patch. All tests pass. Patch includes fix, test case and modifications to the CHANGES.txt file.

> IndexWriter does not release its write lock when trying to open an index which does not yet exist
> -------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-715
>                 URL: http://issues.apache.org/jira/browse/LUCENE-715
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.0.0
>         Environment: Windows XP, Java 1.5, IntelliJ 6
>            Reporter: Matthew Bogosian
>         Attachments: LUCENE-715.patch
>
>
> In version 2.0.0, the private IndexWriter constructor does not properly remove its write lock in the event of an error. This can be seen when one attempts to open (not create) an index in a directory which exists, but in which there is no segments file. Here is the offending code:
>     247   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
>     248     throws IOException {
>     249       this.closeDir = closeDir;
>     250       directory = d;
>     251       analyzer = a;
>     252
>     253       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
>     254       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
>     255         throw new IOException("Index locked for write: " + writeLock);
>     256       this.writeLock = writeLock;                   // save it
>     257
>     258       synchronized (directory) {        // in- & inter-process sync
>     259         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
>     260             public Object doBody() throws IOException {
>     261               if (create)
>     262                 segmentInfos.write(directory);
>     263               else
>     264                 segmentInfos.read(directory);
>     265               return null;
>     266             }
>     267           }.run();
>     268       }
>     269   }
> On line 254, a write lock is obtained by the constructor. If an exception is raised inside the doBody() method (on line 260), then that exception is propagated, the constructor will fail, but the lock is not released until the object is garbage collected. This is typically an issue except when using the IndexModifier class.
> As of the filing of this bug, this has not yet been fixed in the trunk (IndexWriter.java#472959):
>     251   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
>     252     throws IOException {
>     253       this.closeDir = closeDir;
>     254       directory = d;
>     255       analyzer = a;
>     256
>     257       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
>     258       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
>     259         throw new IOException("Index locked for write: " + writeLock);
>     260       this.writeLock = writeLock;                   // save it
>     261
>     262       synchronized (directory) {        // in- & inter-process sync
>     263         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
>     264             public Object doBody() throws IOException {
>     265               if (create)
>     266                 segmentInfos.write(directory);
>     267               else
>     268                 segmentInfos.read(directory);
>     269               return null;
>     270             }
>     271           }.run();
>     272       }
>     273   }

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (LUCENE-715) IndexWriter does not release its write lock when trying to open an index which does not yet exist

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org
    [ http://issues.apache.org/jira/browse/LUCENE-715?page=comments#action_12450861 ]
           
Matthew Bogosian commented on LUCENE-715:
-----------------------------------------

In original description:

s/except when using the IndexModifier class/when using the IndexModifier class/

> IndexWriter does not release its write lock when trying to open an index which does not yet exist
> -------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-715
>                 URL: http://issues.apache.org/jira/browse/LUCENE-715
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.0.0
>         Environment: Windows XP, Java 1.5, IntelliJ 6
>            Reporter: Matthew Bogosian
>         Attachments: LUCENE-715.patch
>
>
> In version 2.0.0, the private IndexWriter constructor does not properly remove its write lock in the event of an error. This can be seen when one attempts to open (not create) an index in a directory which exists, but in which there is no segments file. Here is the offending code:
>     247   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
>     248     throws IOException {
>     249       this.closeDir = closeDir;
>     250       directory = d;
>     251       analyzer = a;
>     252
>     253       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
>     254       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
>     255         throw new IOException("Index locked for write: " + writeLock);
>     256       this.writeLock = writeLock;                   // save it
>     257
>     258       synchronized (directory) {        // in- & inter-process sync
>     259         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
>     260             public Object doBody() throws IOException {
>     261               if (create)
>     262                 segmentInfos.write(directory);
>     263               else
>     264                 segmentInfos.read(directory);
>     265               return null;
>     266             }
>     267           }.run();
>     268       }
>     269   }
> On line 254, a write lock is obtained by the constructor. If an exception is raised inside the doBody() method (on line 260), then that exception is propagated, the constructor will fail, but the lock is not released until the object is garbage collected. This is typically an issue except when using the IndexModifier class.
> As of the filing of this bug, this has not yet been fixed in the trunk (IndexWriter.java#472959):
>     251   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
>     252     throws IOException {
>     253       this.closeDir = closeDir;
>     254       directory = d;
>     255       analyzer = a;
>     256
>     257       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
>     258       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
>     259         throw new IOException("Index locked for write: " + writeLock);
>     260       this.writeLock = writeLock;                   // save it
>     261
>     262       synchronized (directory) {        // in- & inter-process sync
>     263         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
>     264             public Object doBody() throws IOException {
>     265               if (create)
>     266                 segmentInfos.write(directory);
>     267               else
>     268                 segmentInfos.read(directory);
>     269               return null;
>     270             }
>     271           }.run();
>     272       }
>     273   }

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (LUCENE-715) IndexWriter does not release its write lock when trying to open an index which does not yet exist

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org
    [ http://issues.apache.org/jira/browse/LUCENE-715?page=comments#action_12450875 ]
           
Michael McCandless commented on LUCENE-715:
-------------------------------------------

Good catch!  And thanks for the patch.  Plus I like the perl-ese correction above.

It looks like with this patch you are swallowing an IOException if it happens in that try/catch block?  So I think you should add a throw(e) at the end of the catch block?  Also maybe move the try/catch outside the synchronized block?  I usually try to minimize the code inside synchronized blocks, and I don't think the releasing of the writeLock on IOException needs to be inside the synchronized block.

> IndexWriter does not release its write lock when trying to open an index which does not yet exist
> -------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-715
>                 URL: http://issues.apache.org/jira/browse/LUCENE-715
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.0.0
>         Environment: Windows XP, Java 1.5, IntelliJ 6
>            Reporter: Matthew Bogosian
>         Attachments: LUCENE-715.patch
>
>
> In version 2.0.0, the private IndexWriter constructor does not properly remove its write lock in the event of an error. This can be seen when one attempts to open (not create) an index in a directory which exists, but in which there is no segments file. Here is the offending code:
>     247   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
>     248     throws IOException {
>     249       this.closeDir = closeDir;
>     250       directory = d;
>     251       analyzer = a;
>     252
>     253       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
>     254       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
>     255         throw new IOException("Index locked for write: " + writeLock);
>     256       this.writeLock = writeLock;                   // save it
>     257
>     258       synchronized (directory) {        // in- & inter-process sync
>     259         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
>     260             public Object doBody() throws IOException {
>     261               if (create)
>     262                 segmentInfos.write(directory);
>     263               else
>     264                 segmentInfos.read(directory);
>     265               return null;
>     266             }
>     267           }.run();
>     268       }
>     269   }
> On line 254, a write lock is obtained by the constructor. If an exception is raised inside the doBody() method (on line 260), then that exception is propagated, the constructor will fail, but the lock is not released until the object is garbage collected. This is typically an issue except when using the IndexModifier class.
> As of the filing of this bug, this has not yet been fixed in the trunk (IndexWriter.java#472959):
>     251   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
>     252     throws IOException {
>     253       this.closeDir = closeDir;
>     254       directory = d;
>     255       analyzer = a;
>     256
>     257       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
>     258       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
>     259         throw new IOException("Index locked for write: " + writeLock);
>     260       this.writeLock = writeLock;                   // save it
>     261
>     262       synchronized (directory) {        // in- & inter-process sync
>     263         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
>     264             public Object doBody() throws IOException {
>     265               if (create)
>     266                 segmentInfos.write(directory);
>     267               else
>     268                 segmentInfos.read(directory);
>     269               return null;
>     270             }
>     271           }.run();
>     272       }
>     273   }

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (LUCENE-715) IndexWriter does not release its write lock when trying to open an index which does not yet exist

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org
     [ http://issues.apache.org/jira/browse/LUCENE-715?page=all ]

Matthew Bogosian updated LUCENE-715:
------------------------------------

    Attachment: LUCENE-715.patch

Ugh! How embarrassing! If it makes you feel better, I re-raised the exception in my mind.... ;-)

I added the the missing throw statement and moved the try/catch outside of the synchronized block (which is probably even better since it will also take care of the case where the call to makeLock raises an IOException).

Thanks for catching that (no pun intended)!

> IndexWriter does not release its write lock when trying to open an index which does not yet exist
> -------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-715
>                 URL: http://issues.apache.org/jira/browse/LUCENE-715
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.0.0
>         Environment: Windows XP, Java 1.5, IntelliJ 6
>            Reporter: Matthew Bogosian
>         Attachments: LUCENE-715.patch, LUCENE-715.patch
>
>
> In version 2.0.0, the private IndexWriter constructor does not properly remove its write lock in the event of an error. This can be seen when one attempts to open (not create) an index in a directory which exists, but in which there is no segments file. Here is the offending code:
>     247   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
>     248     throws IOException {
>     249       this.closeDir = closeDir;
>     250       directory = d;
>     251       analyzer = a;
>     252
>     253       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
>     254       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
>     255         throw new IOException("Index locked for write: " + writeLock);
>     256       this.writeLock = writeLock;                   // save it
>     257
>     258       synchronized (directory) {        // in- & inter-process sync
>     259         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
>     260             public Object doBody() throws IOException {
>     261               if (create)
>     262                 segmentInfos.write(directory);
>     263               else
>     264                 segmentInfos.read(directory);
>     265               return null;
>     266             }
>     267           }.run();
>     268       }
>     269   }
> On line 254, a write lock is obtained by the constructor. If an exception is raised inside the doBody() method (on line 260), then that exception is propagated, the constructor will fail, but the lock is not released until the object is garbage collected. This is typically an issue except when using the IndexModifier class.
> As of the filing of this bug, this has not yet been fixed in the trunk (IndexWriter.java#472959):
>     251   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
>     252     throws IOException {
>     253       this.closeDir = closeDir;
>     254       directory = d;
>     255       analyzer = a;
>     256
>     257       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
>     258       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
>     259         throw new IOException("Index locked for write: " + writeLock);
>     260       this.writeLock = writeLock;                   // save it
>     261
>     262       synchronized (directory) {        // in- & inter-process sync
>     263         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
>     264             public Object doBody() throws IOException {
>     265               if (create)
>     266                 segmentInfos.write(directory);
>     267               else
>     268                 segmentInfos.read(directory);
>     269               return null;
>     270             }
>     271           }.run();
>     272       }
>     273   }

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (LUCENE-715) IndexWriter does not release its write lock when trying to open an index which does not yet exist

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org
    [ http://issues.apache.org/jira/browse/LUCENE-715?page=comments#action_12450913 ]
           
Michael McCandless commented on LUCENE-715:
-------------------------------------------

Don't worry about it :)  This is what open source is all about!

OK this looks good to me.  I will commit.  Thanks Matthew, keep the patches coming!

> IndexWriter does not release its write lock when trying to open an index which does not yet exist
> -------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-715
>                 URL: http://issues.apache.org/jira/browse/LUCENE-715
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.0.0
>         Environment: Windows XP, Java 1.5, IntelliJ 6
>            Reporter: Matthew Bogosian
>         Attachments: LUCENE-715.patch, LUCENE-715.patch
>
>
> In version 2.0.0, the private IndexWriter constructor does not properly remove its write lock in the event of an error. This can be seen when one attempts to open (not create) an index in a directory which exists, but in which there is no segments file. Here is the offending code:
>     247   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
>     248     throws IOException {
>     249       this.closeDir = closeDir;
>     250       directory = d;
>     251       analyzer = a;
>     252
>     253       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
>     254       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
>     255         throw new IOException("Index locked for write: " + writeLock);
>     256       this.writeLock = writeLock;                   // save it
>     257
>     258       synchronized (directory) {        // in- & inter-process sync
>     259         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
>     260             public Object doBody() throws IOException {
>     261               if (create)
>     262                 segmentInfos.write(directory);
>     263               else
>     264                 segmentInfos.read(directory);
>     265               return null;
>     266             }
>     267           }.run();
>     268       }
>     269   }
> On line 254, a write lock is obtained by the constructor. If an exception is raised inside the doBody() method (on line 260), then that exception is propagated, the constructor will fail, but the lock is not released until the object is garbage collected. This is typically an issue except when using the IndexModifier class.
> As of the filing of this bug, this has not yet been fixed in the trunk (IndexWriter.java#472959):
>     251   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
>     252     throws IOException {
>     253       this.closeDir = closeDir;
>     254       directory = d;
>     255       analyzer = a;
>     256
>     257       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
>     258       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
>     259         throw new IOException("Index locked for write: " + writeLock);
>     260       this.writeLock = writeLock;                   // save it
>     261
>     262       synchronized (directory) {        // in- & inter-process sync
>     263         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
>     264             public Object doBody() throws IOException {
>     265               if (create)
>     266                 segmentInfos.write(directory);
>     267               else
>     268                 segmentInfos.read(directory);
>     269               return null;
>     270             }
>     271           }.run();
>     272       }
>     273   }

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (LUCENE-715) IndexWriter does not release its write lock when trying to open an index which does not yet exist

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org
     [ http://issues.apache.org/jira/browse/LUCENE-715?page=all ]

Michael McCandless resolved LUCENE-715.
---------------------------------------

    Fix Version/s: 2.1
       Resolution: Fixed

> IndexWriter does not release its write lock when trying to open an index which does not yet exist
> -------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-715
>                 URL: http://issues.apache.org/jira/browse/LUCENE-715
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.0.0
>         Environment: Windows XP, Java 1.5, IntelliJ 6
>            Reporter: Matthew Bogosian
>             Fix For: 2.1
>
>         Attachments: LUCENE-715.patch, LUCENE-715.patch
>
>
> In version 2.0.0, the private IndexWriter constructor does not properly remove its write lock in the event of an error. This can be seen when one attempts to open (not create) an index in a directory which exists, but in which there is no segments file. Here is the offending code:
>     247   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
>     248     throws IOException {
>     249       this.closeDir = closeDir;
>     250       directory = d;
>     251       analyzer = a;
>     252
>     253       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
>     254       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
>     255         throw new IOException("Index locked for write: " + writeLock);
>     256       this.writeLock = writeLock;                   // save it
>     257
>     258       synchronized (directory) {        // in- & inter-process sync
>     259         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
>     260             public Object doBody() throws IOException {
>     261               if (create)
>     262                 segmentInfos.write(directory);
>     263               else
>     264                 segmentInfos.read(directory);
>     265               return null;
>     266             }
>     267           }.run();
>     268       }
>     269   }
> On line 254, a write lock is obtained by the constructor. If an exception is raised inside the doBody() method (on line 260), then that exception is propagated, the constructor will fail, but the lock is not released until the object is garbage collected. This is typically an issue except when using the IndexModifier class.
> As of the filing of this bug, this has not yet been fixed in the trunk (IndexWriter.java#472959):
>     251   private IndexWriter(Directory d, Analyzer a, final boolean create, boolean closeDir)
>     252     throws IOException {
>     253       this.closeDir = closeDir;
>     254       directory = d;
>     255       analyzer = a;
>     256
>     257       Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
>     258       if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
>     259         throw new IOException("Index locked for write: " + writeLock);
>     260       this.writeLock = writeLock;                   // save it
>     261
>     262       synchronized (directory) {        // in- & inter-process sync
>     263         new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), commitLockTimeout) {
>     264             public Object doBody() throws IOException {
>     265               if (create)
>     266                 segmentInfos.write(directory);
>     267               else
>     268                 segmentInfos.read(directory);
>     269               return null;
>     270             }
>     271           }.run();
>     272       }
>     273   }

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]