If the computation of a project/portfolio analysis is interrupted while ES indexation is ongoing, the next successful computation of this project/portfolio will update again in ES all the related data and consistency will be automatically restored.
Indeed, as for a project analysis, each time the Compute Engine deals with the computation of a portfolio, all the related data found in DB are indexed:
- views are updated by comparing the content of ES with the DB,
- components, measures and issues are updated by indexing the whole portfolio.
Also, at the end of each project/portfolio analysis, a purge is triggered and some old data are clean out. The purge updates components and issues, deleting the data of past analyses from both the DB and ES. Changes are effectively committed in DB after ES has been updated.
As a consequence, if the purge is interrupted, the purge to be triggered by the next analysis will find again the data in DB and will delete it from ES.
That works when the task / the indexation is interrupted. But, to be able to rely on this mechanism when an error happens while trying to update data in Elasticsearch, we need to make to sure that we catch the errors that can occur so that the task is interrupted.
If a failure happens while indexing the data related to a project/portfolio, the error should be catched, indexation should be interrupted and the task should fail so that the user knows that project/portfolio has to be analyzed again.
If a failure happens during the purge while cleaning up ES, the error should be catched and the purge should be interrupted, the task should fail before changes are committed in DB so that the next analysis can purge again the data.
Full reindexation at server startup
In some cases (upgrade, corruption of data), the content of ES may need to be deleted and fully restored from the DB.
As soon as an indexation request fails, the startup should fail so that the next time the server will start again, the server will drop and restore again the indexes for which indexation was not completed.
We should make sure that, if there's a failure during the import of a project, the import is considered as failed so that the user knows he has to import again the project.