org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out

59 views
Skip to first unread message

Joe Desbonnet

unread,
Feb 25, 2014, 6:39:10 PM2/25/14
to lucene-a...@googlegroups.com
While running lucene-appengine with the local AppEngine development server in Eclipse I'm getting this error a lot:

org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: com.googlecode.lucene.appengine.GaeLockFactory$1@69ad1973

To clear the fault I need to enter the DB admin console at:
and delete the lock record manually.

I'm running lucene-appengine-4.3.0-SNAPSHOT.jar and the Google AppEngine Eclipse plugin version 1.8.9. While developing I'm stopping and restarting the server a lot. I haven't tried this live on Google AppEngine yet.

I have two questions:

1. Can I remove any stale locks programatically? I'm not familiar enough with the various Google AppEngine storage APIs to see how that can be done right now. I can just remove any locks at app boot time if someone could give me pointers on what API I need to use to do this.

2. Any idea what the root cause might be?

Thanks,

Joe.

Joe Desbonnet

unread,
Feb 25, 2014, 8:31:55 PM2/25/14
to lucene-a...@googlegroups.com
Well, figured how to delete the GaeLock programatically. I created a ServletContextListener (and registered it in web.xml) that looks for any GaeLock records at app boot and deleteds them. This *seems* to have made my problem go away :)


public class AppStart implements ServletContextListener {

Logger log = Logger.getLogger(AppStart.class);
@Override
public void contextDestroyed(ServletContextEvent arg0) {
}

@Override
public void contextInitialized(ServletContextEvent arg0) {
// Remove stale GaeLock lock records
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
PreparedQuery pq = datastore.prepare(new Query("GaeLock"));
ArrayList<Key> keys = new ArrayList<Key>();
for (Entity record : pq.asIterable()) {
log.warn("removing stale GaeLock");
keys.add(record.getKey());
}
datastore.delete(keys);
}

}



Joe Desbonnet

unread,
Feb 27, 2014, 12:33:03 PM2/27/14
to lucene-a...@googlegroups.com
Answering the second part of my question, the root cause seems to have been due to a missing close() call on the GaeDirectory. 

Fabio Grucci

unread,
Mar 2, 2014, 8:31:33 AM3/2/14
to
Yes, using that code you can remove any GaeLock entity but be careful: Google AppEngine uses multiple web servers to run your application. If you attach that code to the application startup process you can have some troubles during concurrent indexing. I advice you to move that code into a specific servlet protected accessible with admin rights and to link it onto a custom Administration page.

News for you and for everyone reading, LAE migration to Objectify 4 stable is nearly completed. I think I'll complete everything for the end of March.

Thank you for using LAE

--Fabio Grucci
Reply all
Reply to author
Forward
0 new messages