Lucene.Net和I/O线程问题 [英] Lucene.Net and I/O Threading issue

查看:102
本文介绍了Lucene.Net和I/O线程问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用IndexWriter的索引函数"Execute()"来索引我的网站内容.如果我只是从网页上调用它,则效果很好,但是当我将其作为System.Threading.Thread的委托参数时,它会失败.奇怪的是,它始终在我的本地开发机上运行,​​只有当我上传到共享主机时它才会失败.

这是我收到的错误消息

锁定获取超时:SimpleFSLock错误...."

下面是失败的代码(但仅在共享主机上失败)

Scheduler scheduler = new Scheduler();
System.Threading.Thread schedulerThread = new System.Threading.Thread(scheduler.Execute);

下面是有效的代码(在我的本地计算机和共享主机上均可工作)

Scheduler scheduler = new Scheduler();
schedulre.Execute();

现在,有些人说,这可能是上次调试会话遗留下来的问题,因此在实例化IndexWriter之前,我做了

if (IndexReader.IsLocked(indexingFolder))
{

    log.Debug("it is locked");
    IndexReader.Unlock(FSDirectory.GetDirectory(indexingFolder));
}
else
{
    log.Debug("it is not locked");
}

你猜怎么着?我的日志说,它没有锁定.

所以现在我很确定这是由System.Thread.Threading引起的,但是我不知道如何解决它.

谢谢

解决方案

检查在共享主机上,线程对索引文件夹的权限与在开发机/共享主机上具有的权限相同.

更新:您可以通过查询线程的CurrentPrincipal属性来找到线程正在运行的Principal.尽管这是一个读写属性,但是您可能没有权限在共享主机环境中设置此属性.

您可能会发现此帖子很有帮助. >

I have an indexing function named "Execute()" using IndexWriter to index my site's content. It works great if I simply called it from a web page, but failed when I have it as a delegate parameter into System.Threading.Thread. Strangely though, it always work on my local dev machine, it only fails when I uploads to a shared host.

This is the error message I got

"Lock obtain timed out: SimpleFSLock error...."

Below is the failed code (but only fails on a shared host)

Scheduler scheduler = new Scheduler();
System.Threading.Thread schedulerThread = new System.Threading.Thread(scheduler.Execute);

Below is the code that works (work both on my local machine and on shared host)

Scheduler scheduler = new Scheduler();
schedulre.Execute();

Now, some ppl said, it could be a bad left over from the previous debugging session, so before I instantiated the IndexWriter, I did

if (IndexReader.IsLocked(indexingFolder))
{

    log.Debug("it is locked");
    IndexReader.Unlock(FSDirectory.GetDirectory(indexingFolder));
}
else
{
    log.Debug("it is not locked");
}

and guess what? my log says, it is not locked.

So now I'm pretty sure it's caused by the System.Thread.Threading, but I just have no clue as to how to fix it.

Thanks

解决方案

Check that on the shared host, the thread has the same permissions to the index folder as you do on the development machine/shared host.

Update: You can find what Principal the thread is running under by interrogating the thread's CurrentPrincipal property. Though this is a read-write property, you may not have the permissions to set this property in your shared-host environment.

You might find this post helpful.

这篇关于Lucene.Net和I/O线程问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆