Consider ways to commit repo changes and metadata changes atomically
When repositories are updated, the corresponding metadata is updated afterwards sequentially.
https://github.com/line/centraldogma/blob/d596a340e68598afd981cfd8e3d18f34761f5eb9/server/src/main/java/com/linecorp/centraldogma/server/internal/api/RepositoryServiceV1.java#L125-L127
However, it is possible that operations on repository succeed, but operations on metadata fail.
This scenario has two consequences:
- The UI shows inconsistent states.
- Api calls will fail until the repository and metadata are synced to the same state.
Below is an example where removeRepo fails, but this scenario can happen with any of createRepo, restoreRepo
Sample case
Assume that repository removal succeeds, but the corresponding metadata removal fails
https://github.com/line/centraldogma/blob/d596a340e68598afd981cfd8e3d18f34761f5eb9/server/src/main/java/com/linecorp/centraldogma/server/internal/api/RepositoryServiceV1.java#L146
This means the following patch would've failed, and /repos/{repoName}/removal doesn't exist under dogma/metadata.json.
https://github.com/line/centraldogma/blob/d596a340e68598afd981cfd8e3d18f34761f5eb9/server/src/main/java/com/linecorp/centraldogma/server/metadata/MetadataService.java#L350-L355
From this state there are two problems..
- From the UI, it isn't possible to restore/purge the repository since the UI depends on
dogma/metadata.jsoninformation. (The UI shows that the repository is still in thecreatedstate) - For paths from the API, restoration is possible but an exception will be thrown when trying to update the metadata (
RemoveOperationrequires that the path exists). So the repository will be restored, but the rest API http response will indicate failure.
https://github.com/line/centraldogma/blob/d596a340e68598afd981cfd8e3d18f34761f5eb9/server/src/main/java/com/linecorp/centraldogma/server/metadata/MetadataService.java#L387-L390
I'm still unsure how to approach this issue, but leaving this issue for reference