centraldogma icon indicating copy to clipboard operation
centraldogma copied to clipboard

Consider ways to commit repo changes and metadata changes atomically

Open jrhee17 opened this issue 4 years ago • 0 comments

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:

  1. The UI shows inconsistent states.
  2. 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..

  1. From the UI, it isn't possible to restore/purge the repository since the UI depends on dogma/metadata.json information. (The UI shows that the repository is still in the created state)
  2. For paths from the API, restoration is possible but an exception will be thrown when trying to update the metadata (RemoveOperation requires 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

jrhee17 avatar Dec 23 '21 07:12 jrhee17