Skip to content

fix(plugin-search): serialize reindexing to prevent locale data race conditions#15917

Open
ossaidqadri wants to merge 2 commits intopayloadcms:mainfrom
ossaidqadri:fix-plugin-search-race-condition
Open

fix(plugin-search): serialize reindexing to prevent locale data race conditions#15917
ossaidqadri wants to merge 2 commits intopayloadcms:mainfrom
ossaidqadri:fix-plugin-search-race-condition

Conversation

@ossaidqadri
Copy link
Contributor

Description

This PR fixes a race condition in the plugin-search's reindexing functionality that caused missing locale data when reindexing multiple collections simultaneously.

Changes

  • Replaced Promise.all with sequential processing of collections in generateReindexHandler.ts
  • This change ensures proper handling of locale data during reindexing operations

Motivation

The previous implementation used concurrent execution for collection reindexing, which led to race conditions and incomplete locale data being persisted. The issue was causing non-deterministic failures in localized search indexing.

Fixes #15884

Fix incorrect type name in docs/custom-components/edit-view.mdx
Changed EditViewMenuItemClientProps to EditMenuItemsClientProps to match
the actual exported type from the payload package.

Fixes payloadcms#15898
Copilot AI review requested due to automatic review settings March 11, 2026 20:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a race condition in @payloadcms/plugin-search reindexing by serializing per-collection reindex work so locale create/find/update operations don’t interleave across collections within the same transaction.

Changes:

  • Replaced concurrent Promise.all(collections.map(...)) reindexing with a sequential for...of loop to avoid locale-related data races.
  • Updated docs example type name for custom editMenuItems client component props.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/plugin-search/src/utilities/generateReindexHandler.ts Serializes collection reindexing to prevent concurrent writes that can drop locale data.
docs/custom-components/edit-view.mdx Fixes the documented client props type name for editMenuItems.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ossaidqadri
Copy link
Contributor Author

Hi @jacobsfletch @JarrodMFlesch @AlessioGr @denolfe - would appreciate a review on this PR when you have a chance.

This fixes a race condition in the plugin-search reindexing that causes locale data loss when reindexing multiple collections simultaneously. The fix is straightforward - changing concurrent processing (Promise.all) to sequential processing to prevent transaction conflicts.

Happy to make any adjustments if needed. Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plugin-search]: Reindex All loses locale data due concurrent collection processing race condition

2 participants