lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Isakson" <>
Subject RE: IndexReader.lastModified(); (moved from the User list)
Date Tue, 06 May 2003 14:39:33 GMT
Hmm...I guess I didn't understand the problem so well. Taking a 1 second penalty for every
modification would probably not be a good idea :(

-----Original Message-----
From: Rob Outar [] 
Sent: Tuesday, May 06, 2003 10:33 AM
To: Eric Isakson;
Subject: RE: IndexReader.lastModified(); (moved from the User list)

I have not delved into the source code as much as I would like to but I am not sure if the
below would fix my problem.  Creating the index is OK, but the problem occurs when modifying
the index (which means you need to get a new IndexSearcher).  If the modification to the index
is under 1 second the ext2-fs will not update the last modification date of the index thus
IndexReader.lastModified() useless in terms of checking if the index has changed.  If the
below code is invoked for all modifications to the index then it may work.



-----Original Message-----
From: Eric Isakson []
Sent: Tuesday, May 06, 2003 9:48 AM
Cc: Rob Outar
Subject: RE: IndexReader.lastModified(); (moved from the User list)

Could this be fixed by adding a conditional sleep in this block of code from IndexWriter.
You would use this by setting the System property "org.apache.lucene.SleepOnIndexCreate" to
an int value in milliseconds of how long to sleep when creating a new index. I've attached
a patch. I don't have a linux system to try this out on, perhaps Rob could apply this patch
and see if it fixes his problem.

  public IndexWriter(Directory d, Analyzer a, final boolean create)
       throws IOException {
    directory = d;
    analyzer = a;

    Lock writeLock = directory.makeLock("write.lock");
    if (!writeLock.obtain())                      // obtain write lock
      throw new IOException("Index locked for write: " + writeLock);
    this.writeLock = writeLock;                   // save it

    synchronized (directory) {			  // in- & inter-process sync
      new Lock.With(directory.makeLock("commit.lock")) {
	  public Object doBody() throws IOException {
	    if (create) {
			String sleepOnCreate =
			if (sleepOnCreate != null) {
				try {
					int sleepTime = Integer.parseInt(sleepOnCreate);
				} catch (NumberFormatException e) {
				} catch (InterruptedException e) {
	    return null;

Eric D. Isakson        SAS Institute Inc.
Application Developer  SAS Campus Drive
XML Technologies       Cary, NC 27513
(919) 531-3639

-----Original Message-----
From: Tatu Saloranta []
Sent: Tuesday, May 06, 2003 9:06 AM
To: Lucene Users List
Subject: Re: IndexReader.lastModified();

On Tuesday 06 May 2003 05:42, Rob Outar wrote:
> Yeah it looks like I am going to have to handle it internally instead 
> of relying on IndexReader.lastModified(), oh well so much for 
> cross-platform-ism :-)

[regarding ext2-fs 'feature' on Linux]

I think this 'feature' might be useful thing to document in a FAQ. Perhaps there should be
a platform-dependancies FAQ (or sub-section). Wasn't there also some concern regarding Windows
platform, where deleted status of a file was not reliably accessed by Java (or something similar)?

Also, do you think ext3 has same problem? (or if it has, other new journaling file systems).

-+ Tatu +-

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message