Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET Search Patient by identifier fails for many identifiers in request #6457

Open
jonahermy opened this issue Nov 11, 2024 · 0 comments
Open

Comments

@jonahermy
Copy link

Describe the bug
When invoking a GET /Patient?identifier=a,b,c,d,... with a high number of search values, then hapi does not respond at all and runs into a timeout.
There seems to be a limit for values to pass as the search works about equally fast for ~20 identifiers, but adding then a single more results in the erronous behavior.

To Reproduce
The problem exists on version 6.10, but the issue is reproducible with the latest version (7.7 - http://hapi.fhir.org/baseR4) as well.

POST the following Patient resource:

{
    "resourceType": "Patient",
    "identifier": [
        {
            "use": "official",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1",
            "value": "083fc777-e6e2-4863-8e55-996bdd651f41"
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "04139f3f-8966-48b5-ade6-0b81e31f4840",
            "period": {
                "end": "2024-11-08T12:59:26+00:00"
            }
        },
        {
            "use": "official",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "0feda4fc-f56e-4841-9081-62de4ea7876e"
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "330cd45d-3e5d-464d-a711-1662f5169725",
            "period": {
                "end": "2024-11-08T10:11:51+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "331c8655-d21c-4495-9681-c2c563c45d19",
            "period": {
                "end": "2024-11-08T11:22:22+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "3cf6ed52-267b-4a90-8f51-09e5a7ca2eeb",
            "period": {
                "end": "2024-11-08T13:06:11+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "3f1e6406-ca82-4d7b-8bdc-33777d8bc322",
            "period": {
                "end": "2024-11-08T10:28:41+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "76972015-2c87-4050-8f7d-c19bcd1d2a58",
            "period": {
                "end": "2024-11-08T12:50:27+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "7b38f2d9-83a3-49ce-b0b2-19a0a5c5a10f",
            "period": {
                "end": "2024-11-08T13:06:33+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "847b423d-9ece-4fa8-8151-4dfcd4a24ece",
            "period": {
                "end": "2024-11-08T12:53:38+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "8a82844c-bc2c-4b18-8d0d-72f03a0eeee9",
            "period": {
                "end": "2024-11-08T12:49:38+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "8f6ec33f-ebf4-4a7a-92ad-cf17c3db426e",
            "period": {
                "end": "2024-11-08T11:21:18+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "91ebdeff-52cd-4ed7-88ff-0e2315eea03b",
            "period": {
                "end": "2024-11-08T12:51:10+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "96d78622-852c-4de9-bcdb-b14cd2292d06",
            "period": {
                "end": "2024-11-08T12:44:11+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "c7c60513-495e-42b0-9dd0-8ae2b7371086",
            "period": {
                "end": "2024-11-08T10:36:02+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "d5c34548-9992-457c-8b7c-b771a686677a",
            "period": {
                "end": "2024-11-08T12:55:45+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "e0a24aac-d534-4f61-b3ec-2f9678c1c60e",
            "period": {
                "end": "2024-11-08T10:27:45+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "e0d3b9e5-8103-40ce-96f3-daeb50e1fa81",
            "period": {
                "end": "2024-11-08T12:54:28+00:00"
            }
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "f17e3e12-8a46-4f0e-ba1d-5b19bb3873a3",
            "period": {
                "end": "2024-11-08T10:13:51+00:00"
            }
        },
        {
            "use": "official",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "fa973a54-8b71-4a40-b03f-9f8ec53a6cc5"
        },
        {
            "use": "old",
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "PI"
                    }
                ]
            },
            "system": "urn:oid:1.1.1.4.555",
            "value": "feebbea1-4541-4026-8073-13635a8ef7de",
            "period": {
                "end": "2024-11-08T10:33:23+00:00"
            }
        }
    ],
    "active": true,
    "name": [
        {
            "use": "official",
            "family": "identifier-test-last",
            "given": [
                "identifier-test-first"
            ]
        }
    ],
    "telecom": [
        {
            "system": "email",
            "value": "[email protected]",
            "use": "home"
        },
        {
            "system": "email",
            "value": "[email protected]",
            "use": "home"
        }
    ],
    "gender": "male",
    "birthDate": "2024-10-31",
    "managingOrganization": {
        "type": "Organization",
        "identifier": {
            "system": "urn:ietf:rfc:3986",
            "value": "urn:oid:1.1.1.4.555"
        }
    }
}

Now query it by a lot of identifiers with- and without system, some matching, some not:
GET http://hapi.fhir.org/baseR4/Patient?identifier=04139f3f-8966-48b5-ade6-0b81e31f4840,083cf97a-93e2-4cbd-86c9-704542ceb794,083fc777-e6e2-4863-8e55-996bdd651f41,0feda4fc-f56e-4841-9081-62de4ea7876e,330cd45d-3e5d-464d-a711-1662f5169725,331c8655-d21c-4495-9681-c2c563c45d19,3cf6ed52-267b-4a90-8f51-09e5a7ca2eeb,3f1e6406-ca82-4d7b-8bdc-33777d8bc322,573da5d0-4e0f-4b09-9a3a-27482217381f,76972015-2c87-4050-8f7d-c19bcd1d2a58,7b38f2d9-83a3-49ce-b0b2-19a0a5c5a10f,847b423d-9ece-4fa8-8151-4dfcd4a24ece,8a82844c-bc2c-4b18-8d0d-72f03a0eeee9,8f6ec33f-ebf4-4a7a-92ad-cf17c3db426e,91ebdeff-52cd-4ed7-88ff-0e2315eea03b,96d78622-852c-4de9-bcdb-b14cd2292d06,c7c60513-495e-42b0-9dd0-8ae2b7371086,d5c34548-9992-457c-8b7c-b771a686677a,e013cecc-e064-4b62-97fc-5499983d7ea8,e0a24aac-d534-4f61-b3ec-2f9678c1c60e,e0d3b9e5-8103-40ce-96f3-daeb50e1fa81,f17e3e12-8a46-4f0e-ba1d-5b19bb3873a3,fa973a54-8b71-4a40-b03f-9f8ec53a6cc5,feebbea1-4541-4026-8073-13635a8ef7de,urn%3Aoid%3A1.1.1.4.555%7C04139f3f-8966-48b5-ade6-0b81e31f4840,urn%3Aoid%3A1.1.1.4.555%7C083cf97a-93e2-4cbd-86c9-704542ceb794,urn%3Aoid%3A1.1.1.4.555%7C0feda4fc-f56e-4841-9081-62de4ea7876e,urn%3Aoid%3A1.1.1.4.555%7C330cd45d-3e5d-464d-a711-1662f5169725,urn%3Aoid%3A1.1.1.4.555%7C331c8655-d21c-4495-9681-c2c563c45d19,urn%3Aoid%3A1.1.1.4.555%7C3cf6ed52-267b-4a90-8f51-09e5a7ca2eeb,urn%3Aoid%3A1.1.1.4.555%7C3f1e6406-ca82-4d7b-8bdc-33777d8bc322,urn%3Aoid%3A1.1.1.4.555%7C573da5d0-4e0f-4b09-9a3a-27482217381f,urn%3Aoid%3A1.1.1.4.555%7C76972015-2c87-4050-8f7d-c19bcd1d2a58,urn%3Aoid%3A1.1.1.4.555%7C7b38f2d9-83a3-49ce-b0b2-19a0a5c5a10f,urn%3Aoid%3A1.1.1.4.555%7C847b423d-9ece-4fa8-8151-4dfcd4a24ece,urn%3Aoid%3A1.1.1.4.555%7C8a82844c-bc2c-4b18-8d0d-72f03a0eeee9,urn%3Aoid%3A1.1.1.4.555%7C8f6ec33f-ebf4-4a7a-92ad-cf17c3db426e,urn%3Aoid%3A1.1.1.4.555%7C91ebdeff-52cd-4ed7-88ff-0e2315eea03b,urn%3Aoid%3A1.1.1.4.555%7C96d78622-852c-4de9-bcdb-b14cd2292d06,urn%3Aoid%3A1.1.1.4.555%7Cc7c60513-495e-42b0-9dd0-8ae2b7371086,urn%3Aoid%3A1.1.1.4.555%7Cd5c34548-9992-457c-8b7c-b771a686677a,urn%3Aoid%3A1.1.1.4.555%7Ce013cecc-e064-4b62-97fc-5499983d7ea8,urn%3Aoid%3A1.1.1.4.555%7Ce0a24aac-d534-4f61-b3ec-2f9678c1c60e,urn%3Aoid%3A1.1.1.4.555%7Ce0d3b9e5-8103-40ce-96f3-daeb50e1fa81,urn%3Aoid%3A1.1.1.4.555%7Cf17e3e12-8a46-4f0e-ba1d-5b19bb3873a3,urn%3Aoid%3A1.1.1.4.555%7Cfa973a54-8b71-4a40-b03f-9f8ec53a6cc5,urn%3Aoid%3A1.1.1.4.555%7Cfeebbea1-4541-4026-8073-13635a8ef7de,urn%3Aoid%3A1.1.1%7C083fc777-e6e2-4863-8e55-996bdd651f41&_count=20

This results in a timeout.
Now remove the identifiers one by one and try to execute the query again.
The point is reached from timeout duration to ~500ms for the search.
The first one that worked for me was:
http://hapi.fhir.org/baseR4/Patient?identifier=04139f3f-8966-48b5-ade6-0b81e31f4840,083cf97a-93e2-4cbd-86c9-704542ceb794,083fc777-e6e2-4863-8e55-996bdd651f41,0feda4fc-f56e-4841-9081-62de4ea7876e,330cd45d-3e5d-464d-a711-1662f5169725,331c8655-d21c-4495-9681-c2c563c45d19,3cf6ed52-267b-4a90-8f51-09e5a7ca2eeb,3f1e6406-ca82-4d7b-8bdc-33777d8bc322,573da5d0-4e0f-4b09-9a3a-27482217381f,76972015-2c87-4050-8f7d-c19bcd1d2a58,7b38f2d9-83a3-49ce-b0b2-19a0a5c5a10f,847b423d-9ece-4fa8-8151-4dfcd4a24ece,8a82844c-bc2c-4b18-8d0d-72f03a0eeee9,8f6ec33f-ebf4-4a7a-92ad-cf17c3db426e,91ebdeff-52cd-4ed7-88ff-0e2315eea03b,96d78622-852c-4de9-bcdb-b14cd2292d06,c7c60513-495e-42b0-9dd0-8ae2b7371086,d5c34548-9992-457c-8b7c-b771a686677a,e013cecc-e064-4b62-97fc-5499983d7ea8,e0a24aac-d534-4f61-b3ec-2f9678c1c60e,e0d3b9e5-8103-40ce-96f3-daeb50e1fa81,f17e3e12-8a46-4f0e-ba1d-5b19bb3873a3,fa973a54-8b71-4a40-b03f-9f8ec53a6cc5&_count=20

Expected behavior
The search also works with many identifiers.

Environment (please complete the following information):

Additional context
According to the hibernate debug logs on local reproduction with 20 identifiers, there are three Search entititys (ca.uhn.fhir.jpa.entity.Search), for myVersion=1; myVersion=2; and myVersion=3.
If one more identifier is added to the search, 21 identifiers in total, there are 237 of these Search entities printed (myVersion=1; [...]; myVersion=237) before the following exception stops the seemingly endless loop:
ca.uhn.fhir.rest.server.exceptions.InternalErrorException: HAPI-1163: Request timed out after 60070ms
at ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl.getResources(SearchCoordinatorSvcImpl.java:284)
at ca.uhn.fhir.jpa.search.PersistedJpaBundleProvider.doSearchOrEverything(PersistedJpaBundleProvider.java:258)
at ca.uhn.fhir.jpa.search.PersistedJpaBundleProvider.getResources(PersistedJpaBundleProvider.java:380)
at ca.uhn.fhir.jpa.search.PersistedJpaSearchFirstPageBundleProvider.getResources(PersistedJpaSearchFirstPageBundleProvider.java:109)
at ca.uhn.fhir.rest.server.method.ResponseBundleBuilder.pagingBuildResourceList(ResponseBundleBuilder.java:160)
at ca.uhn.fhir.rest.server.method.ResponseBundleBuilder.buildResponsePage(ResponseBundleBuilder.java:112)
at ca.uhn.fhir.rest.server.method.ResponseBundleBuilder.buildResponseBundle(ResponseBundleBuilder.java:57)
at ca.uhn.fhir.rest.server.method.BaseResourceReturningMethodBinding.doInvokeServer(BaseResourceReturningMethodBinding.java:201)
at ca.uhn.fhir.rest.server.method.BaseResourceReturningMethodBinding.invokeServer(BaseResourceReturningMethodBinding.java:275)
at ca.uhn.fhir.rest.server.RestfulServer.handleRequest(RestfulServer.java:1190)
at ca.uhn.fhir.rest.server.RestfulServer.doGet(RestfulServer.java:420)
at ca.uhn.fhir.rest.server.RestfulServer.service(RestfulServer.java:1923)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant