mirror of https://github.com/milvus-io/milvus.git
Fix DeleteCollection not protected (#25599)
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/25630/head
parent
69d274d233
commit
a7e6f08183
|
@ -232,8 +232,13 @@ func DeleteCollection(collection *Collection) {
|
||||||
void
|
void
|
||||||
deleteCollection(CCollection collection);
|
deleteCollection(CCollection collection);
|
||||||
*/
|
*/
|
||||||
|
collection.mu.Lock()
|
||||||
|
defer collection.mu.Unlock()
|
||||||
|
|
||||||
cPtr := collection.collectionPtr
|
cPtr := collection.collectionPtr
|
||||||
C.DeleteCollection(cPtr)
|
if cPtr != nil {
|
||||||
|
C.DeleteCollection(cPtr)
|
||||||
|
}
|
||||||
|
|
||||||
collection.collectionPtr = nil
|
collection.collectionPtr = nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import (
|
||||||
"github.com/cockroachdb/errors"
|
"github.com/cockroachdb/errors"
|
||||||
|
|
||||||
"github.com/milvus-io/milvus/internal/proto/querypb"
|
"github.com/milvus-io/milvus/internal/proto/querypb"
|
||||||
|
"github.com/milvus-io/milvus/pkg/util/merr"
|
||||||
. "github.com/milvus-io/milvus/pkg/util/typeutil"
|
. "github.com/milvus-io/milvus/pkg/util/typeutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -178,6 +179,10 @@ func NewRetrievePlan(col *Collection, expr []byte, timestamp Timestamp, msgID Un
|
||||||
col.mu.RLock()
|
col.mu.RLock()
|
||||||
defer col.mu.RUnlock()
|
defer col.mu.RUnlock()
|
||||||
|
|
||||||
|
if col.collectionPtr == nil {
|
||||||
|
return nil, merr.WrapErrCollectionNotFound(col.id, "collection released")
|
||||||
|
}
|
||||||
|
|
||||||
var cPlan C.CRetrievePlan
|
var cPlan C.CRetrievePlan
|
||||||
status := C.CreateRetrievePlanByExpr(col.collectionPtr, unsafe.Pointer(&expr[0]), (C.int64_t)(len(expr)), &cPlan)
|
status := C.CreateRetrievePlanByExpr(col.collectionPtr, unsafe.Pointer(&expr[0]), (C.int64_t)(len(expr)), &cPlan)
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,12 @@ func (suite *PlanSuite) TestPlanFail() {
|
||||||
suite.Error(err)
|
suite.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *PlanSuite) TestQueryPlanCollectionReleased() {
|
||||||
|
collection := &Collection{id: suite.collectionID}
|
||||||
|
_, err := NewRetrievePlan(collection, nil, 0, 0)
|
||||||
|
suite.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestPlan(t *testing.T) {
|
func TestPlan(t *testing.T) {
|
||||||
suite.Run(t, new(PlanSuite))
|
suite.Run(t, new(PlanSuite))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue