Skip to content

Commit c5915c8

Browse files
committed
retrieve any (ready/not-ready) task
1 parent b943c6b commit c5915c8

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

go/pkg/sysdb/coordinator/task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (s *Coordinator) AttachFunction(ctx context.Context, req *coordinatorpb.Att
9292
err := s.catalog.txImpl.Transaction(ctx, func(txCtx context.Context) error {
9393
// Check if there's any active (ready, non-deleted) attached function for this collection
9494
// We only allow one active attached function per collection
95-
existingAttachedFunctions, err := s.catalog.metaDomain.AttachedFunctionDb(txCtx).GetByCollectionID(req.InputCollectionId)
95+
existingAttachedFunctions, err := s.catalog.metaDomain.AttachedFunctionDb(txCtx).GetAnyByCollectionID(req.InputCollectionId)
9696
if err != nil {
9797
log.Error("AttachFunction: failed to check for existing attached function", zap.Error(err))
9898
return err

go/pkg/sysdb/metastore/db/dao/task.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,23 @@ func (s *attachedFunctionDb) GetByCollectionID(inputCollectionID string) ([]*dbm
153153
return attachedFunctions, nil
154154
}
155155

156+
// Returns the non-deleted functions, without regard for `is_ready`. Deleted functions will still
157+
// be excluded.
158+
func (s *attachedFunctionDb) GetAnyByCollectionID(inputCollectionID string) ([]*dbmodel.AttachedFunction, error) {
159+
var attachedFunctions []*dbmodel.AttachedFunction
160+
err := s.db.
161+
Where("input_collection_id = ?", inputCollectionID).
162+
Where("is_deleted = ?", false).
163+
Find(&attachedFunctions).Error
164+
165+
if err != nil {
166+
log.Error("GetByCollectionID failed", zap.Error(err), zap.String("input_collection_id", inputCollectionID))
167+
return nil, err
168+
}
169+
170+
return attachedFunctions, nil
171+
}
172+
156173
func (s *attachedFunctionDb) SoftDelete(inputCollectionID string, name string) error {
157174
// Update name and is_deleted in a single query
158175
// Format: _deleted_<original_name>_<id>

go/pkg/sysdb/metastore/db/dbmodel/task.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type IAttachedFunctionDb interface {
4242
GetByID(id uuid.UUID) (*AttachedFunction, error)
4343
GetAnyByID(id uuid.UUID) (*AttachedFunction, error) // TODO(tanujnay112): Consolidate all the getters.
4444
GetByCollectionID(inputCollectionID string) ([]*AttachedFunction, error)
45+
GetAnyByCollectionID(inputCollectionID string) ([]*AttachedFunction, error)
4546
Update(attachedFunction *AttachedFunction) error
4647
Finish(id uuid.UUID) error
4748
SoftDelete(inputCollectionID string, name string) error

0 commit comments

Comments
 (0)