Fix writer deadlock in local store
The local store could end up in a state where the writer is closed but the reference is locked after a commit on an existing object. Cleans up Commit logic to always close the writer even after an error occurs, guaranteeing the reference is unlocked after commit. Adds a test to the content test suite to verify this behavior. Updates the content store interface definitions to clarify the behavior. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
@@ -376,6 +376,9 @@ func (s *service) Write(session api.Content_WriteServer) (err error) {
|
||||
expected = req.Expected
|
||||
|
||||
if _, err := s.store.Info(session.Context(), req.Expected); err == nil {
|
||||
if err := wr.Close(); err != nil {
|
||||
log.G(ctx).WithError(err).Error("failed to close writer")
|
||||
}
|
||||
if err := s.store.Abort(session.Context(), ref); err != nil {
|
||||
log.G(ctx).WithError(err).Error("failed to abort write")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user