lucene-lucene-net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Chiaretta <>
Subject "Lock obtain timed out: SimpleFSLock" appearing sometimes
Date Mon, 04 Jan 2010 21:16:44 GMT
Hi all,
since it's my first time here I'd like to introduce myself.
My name is Simone Chiaretta, and I'm member of Subtext blogging engine team,
and I'm a ASP.NET MVC fan.
I also have a blog at, where I also wrote a few
posts about

But going back to the main topic of this email: I'm implementing a based search engine for Subtext and I'm writing because I've a
strange problem that happens from times to times:
I get the exception of the subject "Lock obtain timed out: SimpleFSLock..."
every now and then when the ApplicationPool recycles.

I know only one IndexWriter can exist at a time, and in fact the writer is a
static variable inside the search engine service.

The problem seems that the Dispose of the search engine, which closes the
writer is not enough for releasing the lock.

        public void Dispose()
            var searcher = _searcher;
            if (searcher != null)

            var writer = _writer;
            if (writer != null)

            var directory = _directory;
            if(directory != null) {

            writer = _writer;
            if (writer != null)
                _writer = null;

For the moment I made 2 workaround that I hope will solve the problem:

I'm checking weather the index is locked or not before creating a new one

        __log.Error("Something left a lock in the index folder: deleting
        __log.Info("Lock Deleted... can proceed");
    _writer = new IndexWriter(_directory, _analyzer);

and I'm explicitly disposing the search engine in the Application_End event
of the WebApplication


But I'd like to know if maybe I'm making some mistake somewhere that is
causing the problem, or if there is a more elegant way to fix this problem.

For a complete reference here is the link to the latest version of the
SearchEngineService class that encapsulate all the fulltext searching logic
of Subtext

Oh... one last thing.. I'm using 2.3.2

Thank you

Simone Chiaretta
Microsoft MVP ASP.NET - ASPInsider
twitter: @simonech

Any sufficiently advanced technology is indistinguishable from magic
"Life is short, play hard"

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message