lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lichtner, Guglielmo" <>
Subject RE: IndexReader In a MultiThreaded Env
Date Sun, 20 Apr 2003 17:54:43 GMT

This should do it, I think:

	//check and build index here
	synchronized (INDEX_LOCK) {
		if (indexReader.indexExists(indexDir)) {
			//build index here
	public static Object INDEX_LOCK = new Object();

Actually, I have used a different method altogether for my index. There is
only one
thread that updates the index (and can create it). And there is a stateless
thread which restarts the indexing thread should it die for any reason

-----Original Message-----
From: Rob Outar []
Sent: Wednesday, April 16, 2003 4:22 PM
To: Lucene Users List
Subject: IndexReader In a MultiThreaded Env

Hi all,

	I think I tracked down what was a nasty bug.  I have 2 threads, my
works in the following way, the first time a user tries to access the index,
if an index does not exists then one is built, otherwise if one is there it
simply uses it.

	Thread 1 comes along and he tries to query, no index exists
(ndexReader.indexExists(File directory) method) so one is now being built.

	Thread 2 comes along he checks if an index exists via the
IndexReader.indexExists(File directory) method <-- it returns true since all
the method does is File.exists().  Since thread one caused an index to be
built Thread 2 thinks that it is a usable index and tries to run queries and
modify the index -- all of which fail because the index is still being

	Is there any method that checks more than if the index directory
exists?  Is there way to make sure the index is valid before using it?

	Let me know.


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

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

View raw message