Skip to content

Whoosh filewriting LockError #47

Closed
rsateler opened this Issue May 19, 2012 · 14 comments

2 participants

@rsateler

When saving a translation, sometimes it just works ok, others will fail with the following error. Is there something I'm doing wrong? Thank you.
On:

  • Debian stable
  • python 2.6.6
  • Whoosh==2.4.0

Environment:

Request Method: POST
Request URL: http://xxx/projects/test/testweb/es/translate/

Django Version: 1.4
Python Version: 2.6.6
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'registration',
'weblate.trans',
'weblate.lang',
'weblate.accounts',
'weblate')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, callback_args, *callback_kwargs) File "/weblate/weblate/trans/views.py" in translate
  2. unit.save_backend(request) File "/weblate/weblate/trans/models.py" in save_backend
  3. self.save(backend = True) File "/weblate/weblate/trans/models.py" in save
  4. Unit.objects.add_to_index(self) File "/weblate/weblate/trans/managers.py" in add_to_index
  5. writer_source) File "/weblate/weblate/trans/managers.py" in add_to_source_index
  6. context = unicode(context), File "/usr/local/lib/python2.6/dist-packages/whoosh/util.py" in synchronized_wrapper
  7. return func(self, args, *kwargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/writing.py" in update_document
  8. self._get_writer() File "/usr/local/lib/python2.6/dist-packages/whoosh/writing.py" in _get_writer
  9. self.writer = self.index.writer(**self.writerargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/fileindex.py" in writer
  10. return SegmentWriter(self, **kwargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filewriting.py" in init
  11. raise LockError

Exception Type: LockError at /projects/test/testweb/es/translate/
Exception Value:

@nijel
Owner
nijel commented May 21, 2012

Might be caused by Whoosh 2.4, I've tested only with 2.3 so far.

@rsateler

Thanks for the advice. I've just uninstalled whoosh and installed whoosh==2.3 (also tried 2.3.2) but now I get a different error, this time happens on every page I visit in weblate.
Any help would be much appreciated.

Environment:

Request Method: GET
Request URL: http://xxx/

Django Version: 1.4
Python Version: 2.6.6
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'registration',
'weblate.trans',
'weblate.lang',
'weblate.accounts',
'weblate')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response

  1. response = middleware_method(request) File "/usr/local/lib/python2.6/dist-packages/django/middleware/locale.py" in process_request
  2. check_path = self.is_language_prefix_patterns_used() File "/usr/local/lib/python2.6/dist-packages/django/middleware/locale.py" in is_language_prefix_patterns_used
  3. for url_pattern in get_resolver(None).url_patterns: File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in url_patterns
  4. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in urlconf_module
  5. self._urlconf_module = import_module(self.urlconf_name) File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py" in import_module
  6. import(name) File "/weblate/weblate/urls.py" in
  7. admin.autodiscover() File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/init.py" in autodiscover
  8. import_module('%s.admin' % app) File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py" in import_module
  9. import(name) File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/admin.py" in
  10. admin.site.register(Group, GroupAdmin) File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in register
  11. validate(admin_class, model) File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/validation.py" in validate
  12. models.get_apps() File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py" in get_apps
  13. self._populate() File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py" in _populate
  14. self.load_app(app_name) File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py" in load_app
  15. models = import_module('.models', app_name) File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py" in import_module
  16. import(name) File "/weblate/weblate/trans/models.py" in
  17. from weblate.trans.managers import TranslationManager, UnitManager, DictionaryManager File "/weblate/weblate/trans/managers.py" in
  18. from whoosh import qparser File "/usr/local/lib/python2.6/dist-packages/whoosh/qparser/init.py" in
  19. from whoosh.qparser.default import * File "/usr/local/lib/python2.6/dist-packages/whoosh/qparser/default.py" in
  20. from whoosh import query File "/usr/local/lib/python2.6/dist-packages/whoosh/query/init.py" in
  21. from whoosh.query.qcore import * File "/usr/local/lib/python2.6/dist-packages/whoosh/query/qcore.py" in
  22. from whoosh import matching File "/usr/local/lib/python2.6/dist-packages/whoosh/matching/init.py" in
  23. from whoosh.matching.mcore import * File "/usr/local/lib/python2.6/dist-packages/whoosh/matching/mcore.py" in
  24. from whoosh.compat import abstractmethod

Exception Type: ImportError at /
Exception Value: cannot import name abstractmethod

@nijel
Owner
nijel commented May 22, 2012

Maybe index files are incompatible, try deleting them (eg. ./manage.py rebuild_index).

@rsateler

Did a fresh install of the python modules (with whoosh 2.3) and weblate and so far is working ok. Thank you for your time!

BTW: great work on weblate!!

@nijel nijel was assigned May 23, 2012
@rsateler

Sorry to open this issue again but the error when saving translations seems to persist (just a bit less frequent than before). The error is the same, but now I realize it's also happening when searching for strings in a subproject's language. May be noted that, just as before, these errors only show sometimes (I would say 30% of the time) and they seem random to me. I'm attaching the output of both errors.

Weblate 1.0
Whoosh 2.3.0


TRANSLATION SAVE ERROR:

Environment:

Request Method: POST
Request URL: http://xxx/projects/test/testweb/en/translate/

Django Version: 1.4
Python Version: 2.6.6
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'registration',
'weblate.trans',
'weblate.lang',
'weblate.accounts',
'weblate')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, callback_args, *callback_kwargs) File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/decorators.py" in _wrapped_view
  2. return view_func(request, args, *kwargs) File "/weblate/weblate/trans/views.py" in translate
  3. unit.save_backend(request) File "/weblate/weblate/trans/models.py" in save_backend
  4. self.save(backend = True) File "/weblate/weblate/trans/models.py" in save
  5. Unit.objects.add_to_index(self) File "/weblate/weblate/trans/managers.py" in add_to_index
  6. writer_source) File "/weblate/weblate/trans/managers.py" in add_to_source_index
  7. context = unicode(context), File "/usr/local/lib/python2.6/dist-packages/whoosh/util.py" in synchronized_wrapper
  8. return func(self, args, *kwargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/writing.py" in update_document
  9. self._get_writer() File "/usr/local/lib/python2.6/dist-packages/whoosh/writing.py" in _get_writer
  10. self.writer = self.index.writer(**self.writerargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/fileindex.py" in writer
  11. return SegmentWriter(self, **kwargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filewriting.py" in init
  12. raise LockError

Exception Type: LockError at /projects/test/testweb/en/translate/
Exception Value:


SEARCH ERROR:

Environment:

Request Method: GET
Request URL: http://xxx/projects/test/testweb/en/translate/?q=what&src=on&tgt=on

Django Version: 1.4
Python Version: 2.6.6
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'registration',
'weblate.trans',
'weblate.lang',
'weblate.accounts',
'weblate')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, callback_args, *callback_kwargs) File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/decorators.py" in _wrapped_view
  2. return view_func(request, args, *kwargs) File "/weblate/weblate/trans/views.py" in translate
  3. allunits = obj.unit_set.search(search_query, search_source, search_context, search_target) File "/weblate/weblate/trans/managers.py" in search
  4. with FULLTEXT_INDEX.source_searcher() as searcher: File "/weblate/weblate/trans/search.py" in source_searcher
  5. return self.source_writer().searcher() File "/usr/local/lib/python2.6/dist-packages/whoosh/writing.py" in searcher
  6. return Searcher(self.reader(), fromindex=self.index, **kwargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/util.py" in synchronized_wrapper
  7. return func(self, args, *kwargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/writing.py" in reader
  8. writer = self._get_writer() File "/usr/local/lib/python2.6/dist-packages/whoosh/writing.py" in _get_writer
  9. self.writer = self.index.writer(**self.writerargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/fileindex.py" in writer
  10. return SegmentWriter(self, **kwargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filewriting.py" in init
  11. raise LockError

Exception Type: LockError at /projects/test/testweb/en/translate/
Exception Value:

@nijel
Owner
nijel commented May 29, 2012

I've actually seen this as well, but for first time after having Weblate few months in heavy use, so it's just probably your workload being quite different to what I have.

Do you have many concurrent changes to single language? I think this would explain such error.

I anyway want to rewrite fulltext index updating so that it is not that intrusive, so this problem will be definitely gone in future versions.

@nijel
Owner
nijel commented May 29, 2012

Traceback for my error:

Traceback (most recent call last):

  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/usr/lib/python2.7/dist-packages/django/contrib/auth/decorators.py", line 20, in _wrapped_view
    return view_func(request, *args, **kwargs)

  File "/usr/lib/python2.7/dist-packages/django/contrib/auth/decorators.py", line 20, in _wrapped_view
    return view_func(request, *args, **kwargs)

  File "/var/lib/django/l10n/weblate/trans/views.py", line 423, in update_translation
    if obj.do_update(request):

  File "/var/lib/django/l10n/weblate/trans/models.py", line 727, in do_update
    return self.subproject.do_update(request)

  File "/var/lib/django/l10n/weblate/trans/models.py", line 354, in do_update
    self.create_translations()

  File "/var/lib/django/l10n/weblate/trans/models.py", line 459, in create_translations
    Translation.objects.update_from_blob(self, code, path, blob_hash, force)

  File "/var/lib/django/l10n/weblate/trans/managers.py", line 86, in update_from_blob
    translation.update_from_blob(blob_hash, force)

  File "/var/lib/django/l10n/weblate/trans/models.py", line 698, in update_from_blob
    newunit = Unit.objects.update_from_unit(self, unit, pos)

  File "/var/lib/django/l10n/weblate/trans/managers.py", line 122, in update_from_unit
    dbunit.update_from_unit(unit, pos, force)

  File "/var/lib/django/l10n/weblate/trans/models.py", line 1065, in update_from_unit
    self.save(force_insert = force, backend = True, same_content = same_content)

  File "/var/lib/django/l10n/weblate/trans/models.py", line 1169, in save
    Unit.objects.add_to_index(self)

  File "/var/lib/django/l10n/weblate/trans/managers.py", line 209, in add_to_index
    writer_target)

  File "/var/lib/django/l10n/weblate/trans/managers.py", line 189, in add_to_target_index
    target = unicode(target),

  File "/usr/lib/python2.7/dist-packages/whoosh/util.py", line 480, in synchronized_wrapper
    return func(self, *args, **kwargs)

  File "/usr/lib/python2.7/dist-packages/whoosh/writing.py", line 599, in update_document
    self._get_writer()

  File "/usr/lib/python2.7/dist-packages/whoosh/writing.py", line 534, in _get_writer
    self.writer = self.index.writer(**self.writerargs)

  File "/usr/lib/python2.7/dist-packages/whoosh/filedb/fileindex.py", line 274, in writer
    return SegmentWriter(self, **kwargs)

  File "/usr/lib/python2.7/dist-packages/whoosh/filedb/filewriting.py", line 135, in __init__
    raise LockError

LockError
@rsateler

I'm testing weblate on my own, so if there is any concurrency, it's just me doing 'F5' on my browser repeatedly (in a search). After I get the first error, then I get it most of the times there is an index usage (search or save).

I anyway want to rewrite fulltext index updating so that it is not that intrusive, so this problem will be definitely gone in future versions.

Sounds great! looking forward to it.

@nijel
Owner
nijel commented Jun 6, 2012
@nijel
Owner
nijel commented Jun 7, 2012

Change implemented in git, needs to be enabled by OFFLOAD_INDEXING option.

It would be great if you could test it in your environment.

@nijel nijel closed this Jun 7, 2012
@rsateler
rsateler commented Jun 7, 2012

Cloned Git (e76210d) and set 'OFFLOAD_INDEXING=True', but still having the same issue when searching or saving a translation. Maybe it's a problem in my system, don't really know whats wrong.


WHEN SEARCHING:

Environment:

Request Method: GET
Request URL: http://server/projects/test/testweb/en/translate/?q=have&src=on&tgt=on

Django Version: 1.4
Python Version: 2.6.6
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'registration',
'weblate.trans',
'weblate.lang',
'weblate.accounts',
'weblate')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, callback_args, *callback_kwargs) File "/weblate/weblate/trans/views.py" in translate
  2. allunits = obj.unit_set.search(search_query, search_source, search_context, search_target) File "/weblate/weblate/trans/managers.py" in search
  3. with FULLTEXT_INDEX.source_searcher() as searcher: File "/weblate/weblate/trans/search.py" in source_searcher
  4. return self.source_writer().searcher() File "/usr/local/lib/python2.6/dist-packages/whoosh/writing.py" in searcher
  5. return Searcher(self.reader(), fromindex=self.index, **kwargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/util.py" in synchronized_wrapper
  6. return func(self, args, *kwargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/writing.py" in reader
  7. writer = self._get_writer() File "/usr/local/lib/python2.6/dist-packages/whoosh/writing.py" in _get_writer
  8. self.writer = self.index.writer(**self.writerargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/fileindex.py" in writer
  9. return SegmentWriter(self, **kwargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filewriting.py" in init
  10. raise LockError

Exception Type: LockError at /projects/test/testweb/en/translate/
Exception Value:


WHEN SAVING TRANSLATION:

Environment:

Request Method: POST
Request URL: http://server/projects/test/testweb/en/translate/

Django Version: 1.4
Python Version: 2.6.6
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'registration',
'weblate.trans',
'weblate.lang',
'weblate.accounts',
'weblate')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, callback_args, *callback_kwargs) File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/decorators.py" in _wrapped_view
  2. return view_func(request, args, *kwargs) File "/weblate/weblate/trans/views.py" in translate
  3. rqtype, File "/weblate/weblate/trans/models.py" in save_backend

File "/weblate/weblate/trans/models.py" in save

  1. def get_source_plurals(self): File "/weblate/weblate/trans/managers.py" in add_to_index
  2. unit.checksum, File "/weblate/weblate/trans/managers.py" in add_to_source_index
  3. context = unicode(context), File "/usr/local/lib/python2.6/dist-packages/whoosh/util.py" in synchronized_wrapper
  4. return func(self, args, *kwargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/writing.py" in update_document
  5. self._get_writer() File "/usr/local/lib/python2.6/dist-packages/whoosh/writing.py" in _get_writer
  6. self.writer = self.index.writer(**self.writerargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/fileindex.py" in writer
  7. return SegmentWriter(self, **kwargs) File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filewriting.py" in init
  8. info = ix._read_toc() File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/fileindex.py" in _read_toc
  9. return _read_toc(self.storage, self._schema, self.indexname) File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/fileindex.py" in _read_toc
  10. % (indexname, storage))

Exception Type: EmptyIndexError at /projects/test/testweb/en/translate/
Exception Value: Index 'source' does not exist in FileStorage('/weblate/weblate/whoosh-index')

@nijel nijel reopened this Jun 17, 2012
@nijel
Owner
nijel commented Jun 17, 2012

Hmm, looks like some bug as it does not seem to work as expected (is updating index while it should not).

@nijel nijel added a commit that referenced this issue Jun 22, 2012
@nijel Use read only searcher when not using buffered indexing
Needed for searching properly work with index offloading (issue #47).
c0a158c
@nijel nijel added a commit that referenced this issue Jun 22, 2012
@nijel Pass flag whether to use buffered indexing
Needed for searching properly work with index offloading (issue #47).
c25c5d7
@nijel
Owner
nijel commented Jun 22, 2012

I think both issues should be now fixed (the change did not cover searching).

@nijel nijel closed this Jun 22, 2012
@rsateler

When saving translations the issue seems to be fixed, no problems so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.