opencrvs / opencrvs-core

A global solution to civil registration
https://www.opencrvs.org
Other
79 stars 58 forks source link

refactor: when reindexing, remove all indices except the latest one #7262

Closed naftis closed 5 days ago

naftis commented 6 days ago

https://github.com/opencrvs/opencrvs-core/blob/0a0f346c035b865dd58777797dae1b54a71cc1d2/packages/search/src/features/reindex/reindex.ts#L52-L62 There is potentially an issue here, when the index is created, if the streaming fails, the updating of indices and pruning might still run here https://github.com/opencrvs/opencrvs-core/blob/49b44e285cdd561b3c0f4a7b5430193afcc21725/packages/search/src/features/reindex/handler.ts#L32-L33 if the client.helpers.bulk throws an error though, that shouldn't happen but the empty index might persist. I'll need to do some error-testing


edit: The index created might stay empty if error is thrown: but when reindexing is run next time, the empty index is pruned. Also the alias isn't being updated to the empty index if an error is being thrown while streaming.