Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock search index while reindexing... #5419

Open
luke- opened this issue Nov 4, 2021 · 6 comments
Open

Lock search index while reindexing... #5419

luke- opened this issue Nov 4, 2021 · 6 comments

Comments

@luke-
Copy link
Contributor

luke- commented Nov 4, 2021

Is your feature request related to a problem? Please describe.

While reindexing the search index via console, new entries may added by queue processing.

See: #3847 (comment)

Describe the solution you'd like

Set some sort of lock.

Describe alternatives you've considered

@marc-farre
Copy link
Collaborator

marc-farre commented Mar 15, 2023

It also can happen with the UpdateDocument jobs executed by queue/run when there are very numerous in the queue: File '/home/web/www/humhub/protected/runtime/searchdb/_oat.fdx' is not readable.:

2023-03-15 11:48:01 [361965] humhub\modules\search\jobs\UpdateDocument (attempt: 1, pid: 1756612) - Done (0.119 s, 14.06 MiB)
PHP Fatal error:  Uncaught ZendSearch\Lucene\Exception\InvalidArgumentException: File '/home/web/www/humhub/protected/runtime/searchdb/_oat.fdx' is not readable. in /home/web/www/humhub/protected/vendor/matthewbdaly/zendsearch/src/ZendSearch/Lucene/Storage/File/Filesystem.php:46
Stack trace:
#0 /home/web/www/humhub/protected/vendor/matthewbdaly/zendsearch/src/ZendSearch/Lucene/Storage/Directory/Filesystem.php(354): ZendSearch\Lucene\Storage\File\Filesystem->__construct()
#1 /home/web/www/humhub/protected/vendor/matthewbdaly/zendsearch/src/ZendSearch/Lucene/Index/SegmentWriter/AbstractSegmentWriter.php(611): ZendSearch\Lucene\Storage\Directory\Filesystem->getFileObject()
#2 /home/web/www/humhub/protected/vendor/matthewbdaly/zendsearch/src/ZendSearch/Lucene/Index/SegmentWriter/DocumentWriter.php(211): ZendSearch\Lucene\Index\SegmentWriter\AbstractSegmentWriter->_generateCFS()
#3 /home/web/www/humhub/protected/vendor/matthewbdaly/zendsearch/src/ZendSearch/Lucene/Index/Writer.php(772): ZendSearch\Lucene\Index\SegmentWriter\DocumentWriter->close()
#4 /home/web/www/humhub/protected/vendor/matthewbdaly/zendsearch/src/ZendSearch/Lucene/Index.php(1199): ZendSearch\Lucene\Index\Writer->commit()
#5 /home/web/www/humhub/protected/vendor/matthewbdaly/zendsearch/src/ZendSearch/Lucene/Index.php(443): ZendSearch\Lucene\Index->commit()
#6 [internal function]: ZendSearch\Lucene\Index->__destruct()
#7 {main}
  thrown in /home/web/www/humhub/protected/vendor/matthewbdaly/zendsearch/src/ZendSearch/Lucene/Storage/File/Filesystem.php on line 46

PS (as a reminder): error logs about search re-indexing are described here: #6168

@luke- luke- modified the milestones: v1.15, v1.16 Jun 29, 2023
@marc-farre
Copy link
Collaborator

https://community.humhub.com/content/perma?id=269660 might be caused by this issue.

@luke-
Copy link
Contributor Author

luke- commented Apr 4, 2024

@yurabakhtin Any idea?

@yurabakhtin
Copy link
Contributor

@luke- I have read the linked issues and as I have understood the main problem is we should stop cron before run the search rebuild process.

I think we could implement an event triggering for CronController::EVENT_BEFORE_ACTION in order to stop any action(cron/daily, cron/hourly, cron/run) of the controller when the search rebuilding is run.

We should detect when the folowing commands are executed:

  • content-search/queue-rebuild
  • content-search/rebuild
  • content-search/optimize - please note we should either remove it or fix it because the method optimize() was deleted for new Search Drivers.

We could set a setting in DB with name like contentSearchIsRebuilding as flag and delete it after the process is finished.

Do you agree?

@luke-
Copy link
Contributor Author

luke- commented Apr 5, 2024

@yurabakhtin

Hmm, I don't know if it's a bit too radical to stop all queue processing during the search rebuild. But that could be a solution. Possibly also for updates/maintenance.

I would prefer to realize this via a mutex: https://www.yiiframework.com/doc/api/2.0/yii-mutex-mutex But here we need a fallback in case the search rebuild crashes...


I originally expected a solution that the ActiveJobs SearchUpdateDocument and SearchDeleteDocument are delayed/skipped during Rebuild with a delayed retry. https://www.yiiframework.com/extension/yiisoft/yii2-queue/doc/guide/2.0/en/retryable#errors-and-retryable-jobs

@yurabakhtin
Copy link
Contributor

@luke- Thanks for the advices, I have implemented it in PR #6934.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants