Race condition: Meilisearch indexes created without primaryKey
## Bug
When Stalwart starts with pending indexing tasks, the task manager's document PUTs can reach Meilisearch before `create_indexes()` completes. Meilisearch auto-creates the index with `primaryKey: null`, and when `create_indexes()` later gets `index_already_exists`, it skips all attribute setup (searchable, filterable, sortable).
All indexing then fails with `index_primary_key_multiple_candidates_found`.
## Reproduction
1. Wipe the Meilisearch database (or start with a fresh instance)
2. Start Stalwart with pending indexing tasks in the queue
3. `st_email` ends up with `primaryKey: null` and no attribute configuration
## Workaround
Stop Stalwart, manually create the index with `primaryKey: "id"` and configure attributes via the Meilisearch API, then restart.
## Environment
- Stalwart 0.15.5
- Meilisearch 1.38.0
关闭于 2026-03-10 2 条评论