milvus-io / milvus

A cloud-native vector database, storage for next generation AI applications
https://milvus.io
Apache License 2.0
30.37k stars 2.91k forks source link

[Bug]: [partial load] the error msg is not fiendly if one of key in dynamic field in the expr and skip_load_dynamic_field=True #36353

Closed yanliang567 closed 3 hours ago

yanliang567 commented 1 month ago

Is there an existing issue for this?

Environment

- Milvus version:  master-20240916-526a672b
- Deployment mode(standalone or cluster):  standalone
- MQ type(rocksmq, pulsar or kafka):     pymilvus-2.5.0rc80

Current Behavior

the error msg is difficult to understand what is going on and how to fix it res = Error(code=65535, message=fail to search on QueryNode 1: worker(1) query failed: Assert "fields_.find(field_id) != fields_.end()" => Cannot find field with field_id: 104 at /workspace/source/internal/core/src/common/Schema.h:171

Expected Behavior

a friendly error msg(it is before 0916 build) {'err_code': 999, 'err_msg': 'field color is dynamic but dynamic field is not loaded'}

Steps To Reproduce

1. create a collection with dynamic field
2. load the collection with skip_load_dynamic_field=True
3. search with one of key in dynamic fields in the expr

Milvus Log

No response

Anything else?

run test below

@pytest.mark.tags(CaseLabel.L1)
    def test_skip_load_dynamic_field(self):
        """
        target: test skip load dynamic field
        method:
        1. create a collection with dynamic field
        2. load
        3. search on dynamic field in expr and/or output_fields
        expected:  search successfully
        4. release and reload with skip load dynamic field=true
        5. search on dynamic field in expr and/or output_fields
        expected: raise exception
        """
        self._connect()
        name = cf.gen_unique_str()
        dim = 128
        nb = 2000
        pk_field = cf.gen_int64_field(name='pk', is_primary=True)
        load_int64_field = cf.gen_int64_field(name="int64_load")
        load_string_field = cf.gen_string_field(name="string_load")
        vector_field = cf.gen_float_vec_field(dim=dim)
        schema = cf.gen_collection_schema(fields=[pk_field, load_int64_field, load_string_field, vector_field],
                                          auto_id=True, enable_dynamic_field=True)
        collection_w = self.init_collection_wrap(name=name, schema=schema)
        data = []
        for i in range(nb):
            data.append({
                f"{load_int64_field.name}": i,
                f"{load_string_field.name}": str(i),
                f"{vector_field.name}": [random.uniform(-1, 1) for _ in range(dim)],
                "color": i,
                "tag": i,
            })
        collection_w.insert(data)

        # build index
        collection_w.create_index(field_name=vector_field.name, index_params=ct.default_index)
        collection_w.load()
        # search
        search_params = ct.default_search_params
        nq = 2
        search_vectors = cf.gen_vectors(nq, dim)
        res, _ = collection_w.search(data=search_vectors, anns_field=vector_field.name, param=search_params,
                                     expr="color > 0",
                                     limit=100, output_fields=["*"],
                                     check_task=CheckTasks.check_search_results,
                                     check_items={"nq": nq, "limit": 100})

        collection_w.release()
        collection_w.load(load_fields=[pk_field.name, vector_field.name, load_string_field.name],
                          skip_load_dynamic_field=True)

        error = {ct.err_code: 999, ct.err_msg: f"field color is dynamic but dynamic field is not loaded"}
        collection_w.search(data=search_vectors, anns_field=vector_field.name, param=search_params,
                            expr="color > 0", limit=100, output_fields=["*"],
                            check_task=CheckTasks.err_res, check_items=error)
yanliang567 commented 1 month ago

/assign @congqixia this is a regression issue. I guess it was injected by improvement of retrieve partial of dynamic fields. /unassign

stale[bot] commented 1 day ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Rotten issues close after 30d of inactivity. Reopen the issue with /reopen.

yanliang567 commented 3 hours ago

verified on master-20241108-bc9562fe-amd64