Make updateSiblings and resetChildrenIndexBy fully async#426
Conversation
The updateDataObject and updateDocument event subscribers were calling IndexElementIndexService::updateSiblings() and resetChildrenIndexBy() synchronously, which made blocking calls to the search provider during HTTP requests. This caused significant slowdowns for large folders. Dispatch an UpdateSiblingsMessage via the message bus so that sibling and children index updates are processed asynchronously through the existing queue infrastructure, consistent with how updateData() works.
Tests cover: - UpdateSiblingsHandler: verifies service method dispatch based on element type, sort-by-index flag, resetChildrenIndexBy flag, and null element handling - DataObjectIndexUpdateSubscriber: verifies UpdateSiblingsMessage is dispatched with correct parameters - DocumentIndexUpdateSubscriber: same verification for documents
|
|
Follow up PR: cancan101#2 |
There was a problem hiding this comment.
Hello @cancan101 ,
thanks for the pr, could you merge the current 2026.x again? This should fix the failing tests.
I noticed a few things:
resetChildrenIndexBy()fills the sharedBulkOperationServicebuffer but never
callscommit()(unlikeupdateSiblings(), seeIndexElementIndexService.php:77).- I guess we need to consult
SynchronousProcessingServiceInterfaceas well here, because CLI and tests enable synchronous mode and expect direct results UpdateSiblingsMessagegets dispatched on every save, ignoring theisInstalledguard inupdateData
How do you want to handle the follow up? Merge this pr first, then rebase the follow up to 2026.x in pimcore/gdi?
| if ($event->getObject()->getChildrenSortBy() === AbstractObject::OBJECT_CHILDREN_SORT_BY_INDEX) { | ||
| $this->indexElementIndexService->resetChildrenIndexBy($event->getObject()); | ||
| } | ||
| $this->messageBus->dispatch( |
There was a problem hiding this comment.
Move the isInstalled guard up here? Or at least check it here as well?
| && $element instanceof AbstractObject | ||
| && $element->getChildrenSortBy() === AbstractObject::OBJECT_CHILDREN_SORT_BY_INDEX | ||
| ) { | ||
| $this->indexElementIndexService->resetChildrenIndexBy($element); |
There was a problem hiding this comment.
commit() missing here, either add it to message, or probably even at the end of resetChildrenIndexBy method itself.
- Commit the bulk buffer at the end of resetChildrenIndexBy() so children index resets are actually flushed to the search index (previously the buffer was filled via addUpdate() but never committed). - Respect synchronous processing in the update subscribers: dispatch UpdateSiblingsMessage with a SYNC TransportNamesStamp when SynchronousProcessingService is enabled, so CLI commands and tests get direct, synchronous results (mirrors QueueMessagesDispatcher). - Guard the message dispatch behind Installer::isInstalled() in updateDataObject()/updateDocument() so no message is dispatched when the bundle is not installed, matching the existing guard in updateData(). - Extend the subscriber unit tests to cover the synchronous-dispatch and not-installed paths. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017t757oNTEGGJYPTdnTaMsA
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017t757oNTEGGJYPTdnTaMsA
|



Changes in this pull request
Resolves #389
Additional info
DataObjectIndexUpdateSubscriber::updateDataObject()andDocumentIndexUpdateSubscriber::updateDocument()were callingIndexElementIndexService::updateSiblings()andresetChildrenIndexBy()synchronously, making blocking calls to the search provider (e.g. OpenSearch/Elasticsearch) during HTTP requestsUpdateSiblingsMessageandUpdateSiblingsHandlerto dispatch sibling/children index updates via the Symfony Messenger bus, so they are processed asynchronously through the existingpimcore_generic_data_index_queuetransportIndexElementIndexServiceInterfacedependency from both event subscribers, replacing it withMessageBusInterfaceto dispatch the new messageThis eliminates the synchronous search-provider roundtrips that caused significant slowdowns during object updates, especially for large folders.
Test plan
UpdateSiblingsMessageto the queue instead of blockingUpdateSiblingsMessageto the queue instead of blockingresetChildrenIndexByis triggered for data objects withOBJECT_CHILDREN_SORT_BY_INDEXsort modeconfig/pimcore/messenger.yaml