-
Notifications
You must be signed in to change notification settings - Fork 43
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
Orion-LD Pagination issue when using offset and limit #1573
Comments
ok, noted. I imagine this bug you've found is a side effect from when I implemented the entity maps, a few months back. I'll start with this first thing tomorrow. Had a fire to put out today, after a few days away on a trip. |
As for your test directly against mongo, to make it a better comparison, order the entities by their |
I implemented a functional test with 22 entities: https://github.com/FIWARE/context.Orion-LD/pull/1575/files
Works like a charm. I tried with [ I added a short sleep in my entity creation loop, to make sure the createdAt for the entities are "in order". ] |
Hello, Thant for your response. We didn't use -experimental or -mongocOnly , Here's the orion part in the Docker compose file we utilized:
Actually, we don't just have 22 entities, we have thousands. However, setting a small limit as 10 or 11, allows us to easily identify replicated and missing elements.
I think that instead of capturing the time of entity creation, it records the times when the request was made. This explains why we have the same creDate for a lot of entities, and why we are encountring replicated and missing entities. |
Ah, you have the EXACT SAME creDate ... [ I added that sleep in my functest to make sure I didn't have a problem like this ] One solution would be to order by |
Think I found it in SOF: https://stackoverflow.com/questions/31209628/sorting-by-subfields-in-mongo-c-driver I'll implement that and create a new functest, one that creates 22 (for example) entities using a BATCH Create operation. This should be easy. |
Yes, I think that ordering by creDate and _Id.id is the solution. I have tested it, and it worked. |
As expected, easy fix - PR sent. |
PR merged. |
So, please try with the new image and if all is good, go ahead and close this issue |
Hello, |
At your service :) |
When using Orion-LD versions 1.5.1 and 1.6.1, we encountered some issues with entity retrieval and pagination.
If we set a limit that is inferior to the total number of entities and use pagination with offsets, some entities are messing while others are duplicated.
For instance, in a GET request with a limit of 10, we observe the duplication of urn: Site:C00002:
GET ("FIWARE_HOST")+"/ngsi-ld/v1/entities?type=Site&count=true&limit=10&count=true&offset="+msg.offset;
Page 1:
1-urn:Site:testSite2
2-urn:Site:testSite3
3-urn:Site:testSite1
4-urn:Site:TestElec2ElasticC
5-urn:Site:C00007
6-urn:Site:C00006
7-urn:Site:C00005
8-urn:Site:C00008
9-urn:Site:C00004
10-urn:Site:C00002
Page 2:
11-urn:Site:C00002
12-urn:Site:C00003
13-urn:Site:C00001
14-urn:Site:335902
15-urn:Site:339216
16-urn:Site:149631
17-urn:Site:333183
18-urn:Site:343679
19-urn:Site:335808
20-urn:Site:219451
We noticed that using the same limit consistently produced identical outcomes, including the same missing and duplicated elements. However, modifying the limit resulted in different set of results with different set of missing and duplicated elements. Those are the results for a limit of 11.
Page 1:
1-urn:Site:testSite2
2-urn:Site:testSite3
3-urn:Site:testSite1
4-urn:Site:TestElec2ElasticC
5-urn:Site:C00008
6-urn:Site:C00007
7-urn:Site:C00006
8-urn:Site:C00009
9-urn:Site:C00005
10-urn:Site:C00004
11-urn:Site:C00002
Page 2:
12-urn:Site:C00003
13-urn:Site:C00001
14-urn:Site:343679
15-urn:Site:350006
16-urn:Site:149631
17-urn:Site:335902
18-urn:Site:350511
19-urn:Site:339216
20-urn:Site:219451
21-urn:Site:330903
22-urn:Site:333183
To identify the root cause, we directly queried the entities from mongodb database and did not encounter the same issue, indicating a potential issue with the way Orion retrieves data from mongodb.
db.entities.find({"_id.type": "Site"}, {attrs:0,attrNames:0,creDate:0,modDate:0, lastCorrelator:0, _id:1}).limit(10);
1-{ "_id" : { "id" : "urn:Site:testSite1", "type" : "Site", "servicePath" : "/" } }
2-{ "_id" : { "id" : "urn:Site:testSite2", "type" : "Site", "servicePath" : "/" } }
3-{ "_id" : { "id" : "urn:Site:testSite3", "type" : "Site", "servicePath" : "/" } }
4-{ "_id" : { "id" : "urn:Site:TestElec2ElasticC", "type" : "Site", "servicePath" : "/" } }
5-{ "_id" : { "id" : "urn:Site:C00001", "type" : "Site", "servicePath" : "/" } }
6-{ "_id" : { "id" : "urn:Site:C00002", "type" : "Site", "servicePath" : "/" } }
7-{ "_id" : { "id" : "urn:Site:C00003", "type" : "Site", "servicePath" : "/" } }
8-{ "_id" : { "id" : "urn:Site:C00004", "type" : "Site", "servicePath" : "/" } }
9-{ "_id" : { "id" : "urn:Site:C00005", "type" : "Site", "servicePath" : "/" } }
10-{ "_id" : { "id" : "urn:Site:C00006", "type" : "Site", "servicePath" : "/" } }
11-{ "_id" : { "id" : "urn:Site:C00007", "type" : "Site", "servicePath" : "/" } }
12-{ "_id" : { "id" : "urn:Site:C00008", "type" : "Site", "servicePath" : "/" } }
13-{ "_id" : { "id" : "urn:Site:C00009", "type" : "Site", "servicePath" : "/" } }
...
The text was updated successfully, but these errors were encountered: