Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasgere committed Apr 23, 2024
1 parent a524270 commit 1e9d988
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions chromadb/db/impl/grpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def update_collection(
dimension: OptionalArgument[Optional[int]] = Unspecified(),
metadata: OptionalArgument[Optional[UpdateMetadata]] = Unspecified(),
) -> None:
print("11123209839083098120983")
write_name = None
if name != Unspecified():
write_name = cast(str, name)
Expand Down Expand Up @@ -295,6 +296,8 @@ def update_collection(
response = self._sys_db_stub.UpdateCollection(request)
if response.status.code == 404:
raise NotFoundError()
if response.status.code == 409:
raise UniqueConstraintError()

def reset_and_wait_for_ready(self) -> None:
self._sys_db_stub.ResetState(Empty(), wait_for_ready=True)
7 changes: 6 additions & 1 deletion go/pkg/coordinator/grpc/collection_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,14 @@ func (s *Server) UpdateCollection(ctx context.Context, req *coordinatorpb.Update
}

_, err = s.coordinator.UpdateCollection(ctx, updateCollection)

if err != nil {
log.Error("error updating collection", zap.Error(err))
res.Status = failResponseWithError(err, errorCode)
if err == common.ErrCollectionUniqueConstraintViolation {
res.Status = failResponseWithError(err, 409)
} else {
res.Status = failResponseWithError(err, errorCode)
}
return res, nil
}

Expand Down
19 changes: 18 additions & 1 deletion go/pkg/metastore/db/dao/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,24 @@ func generateCollectionUpdatesWithoutID(in *dbmodel.Collection) map[string]inter
func (s *collectionDb) Update(in *dbmodel.Collection) error {
log.Info("update collection", zap.Any("collection", in))
updates := generateCollectionUpdatesWithoutID(in)
return s.db.Model(&dbmodel.Collection{}).Where("id = ?", in.ID).Updates(updates).Error
err := s.db.Model(&dbmodel.Collection{}).Where("id = ?", in.ID).Updates(updates).Error
if err != nil {
log.Error("create collection failed", zap.Error(err))
var pgErr *pgconn.PgError
ok := errors.As(err, &pgErr)
if ok {
log.Error("Postgres Error")
switch pgErr.Code {
case "23505":
log.Error("collection already exists")
return common.ErrCollectionUniqueConstraintViolation
default:
return err
}
}
return err
}
return nil
}

func (s *collectionDb) UpdateLogPositionAndVersion(collectionID string, logPosition int64, currentCollectionVersion int32) (int32, error) {
Expand Down

0 comments on commit 1e9d988

Please sign in to comment.