FIWARE / context.Orion-LD

Context Broker and CEF building block for context data management which supports both the NGSI-LD and the NGSI-v2 APIs
https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.06.01_60/gs_CIM009v010601p.pdf
GNU Affero General Public License v3.0
51 stars 43 forks source link

Error: updating subscriptions in Orion-LD #1374

Open mgonzalezlopezudc opened 1 year ago

mgonzalezlopezudc commented 1 year ago

When updating a subscription through _PATCH /ngsi-ld/v1/subscriptions/_, Orion-LD produces the following error:

2023-05-12 14:45:02 time=Friday 12 May 12:45:02 2023.407Z | lvl=TMP | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=orionldMhdConnectionInit.cpp[982]:orionldMhdConnectionInit | msg=------------------------- Servicing NGSI-LD request 237: PATCH /ngsi-ld/v1/subscriptions/urn:ngsi-ld:subscription:7b97a83c-f0be-11ed-9cd1-0242ac120107 -------------------------- 2023-05-12 14:45:02 time=Friday 12 May 12:45:02 2023.410Z | lvl=ERROR | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=mongocSubscriptionReplace.cpp[68]:mongocSubscriptionReplace | msg=mongoc error replacing subscription 'urn:ngsi-ld:subscription:7b97a83c-f0be-11ed-9cd1-0242ac120107': [17.66]: After applying the update, the (immutable) field '_id' was found to have been altered to _id: "urn:ngsi-ld:subscription:7b97a83c-f0be-11ed-9cd1-0242ac120107"

Interestingly, the error does not happen if the subscription to be updated is the first one in the array of subscriptions returned by GET /ngsi-ld/v1/subscriptions. However, any change in the "description" attribute of the subscription is not processed if Orion-LD is running with the -experimental flag. If the flag is not set, changes in the "description" attribute are processed correctly.

I am attaching a Postman collection for easy reproduction of the error. I was working with the following tutorial: https://ngsi-ld-tutorials.readthedocs.io/en/latest/time-series-data.html

NGSI-LD Subscription Update BUG.postman_collection.json.zip

kzangeli commented 1 year ago

Hi, thanks for reporting!

I think I might have fixed this issue already, just a week ago, in pull request #1369 What version of Orion-LD are you using?

mgonzalezlopezudc commented 1 year ago

1.2.0


From: Ken Zangelin @.> Sent: Friday, May 12, 2023 3:17:46 PM To: FIWARE/context.Orion-LD @.> Cc: Miguel González López @.>; Author @.> Subject: Re: [FIWARE/context.Orion-LD] Error: updating subscriptions in Orion-LD (Issue #1374)

Hi, thanks for reporting!

I think I might have fixed this issue already, just a week ago, in pull request #1369https://github.com/FIWARE/context.Orion-LD/pull/1369 What version of Orion-LD are you using?

— Reply to this email directly, view it on GitHubhttps://github.com/FIWARE/context.Orion-LD/issues/1374#issuecomment-1545732898, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AN5IJVL5ZTJDQPLJRDSPNTDXFYZ7VANCNFSM6AAAAAAX7QE3LI. You are receiving this because you authored the thread.Message ID: @.***>

kzangeli commented 1 year ago

ok, please try the latest image from dockerhub. I fixed this just after releasing 1.2.0 and will release a 1.2.1 today or this weekend

kzangeli commented 1 year ago

If this issue you've found is not fixed, then I will fix it before creating the 1.2.1, naturally

mgonzalezlopezudc commented 1 year ago

Main issue solved in the latest Docker Hub image. However, the issue of not updating changes in the "description" attribute remains.

kzangeli commented 1 year ago

ok! I will look into that right away then!

kzangeli commented 1 year ago

ok, I have reproduced the bug, and you are right, the "description" field is not updated. It is not updated in the Subscription Cache, which is where "GET /subscriptions/{subId}" takes it from, by default. It is however updated in the database (menos mal), and if you use the non-NGSI-LD URL option "?options=fromDb", then Orion-LD takes the subscription from the database instead and you get the expected result back.

Anyway, that's just a temporary work-around, if you want to use it. It is clearly a bug and I will fix it RIGHT NOW. And then v1.2.1.

Again, thank you for reporting!!!

mgonzalezlopezudc commented 1 year ago

Thanks a lot Ken! Your reply to this issue could not be quicker. Thank you very much also for the detailed explanations.


From: Ken Zangelin @.> Sent: Friday, May 12, 2023 4:25:26 PM To: FIWARE/context.Orion-LD @.> Cc: Miguel González López @.>; Author @.> Subject: Re: [FIWARE/context.Orion-LD] Error: updating subscriptions in Orion-LD (Issue #1374)

ok, I have reproduced the bug, and you are right, the "description" field is not updated. It is not updated in the Subscription Cache, which is where "GET /subscriptions/{subId}" takes it from, by default. It is however updated in the database (menos mal), and if you use the non-NGSI-LD URL option "?options=fromDb", then Orion-LD takes the subscription from the database instead and you get the expected result back.

Anyway, that's just a temporary work-around, if you want to use it. It is clearly a bug and I will fix it RIGHT NOW. And then v1.2.1.

Again, thank you for reporting!!!

— Reply to this email directly, view it on GitHubhttps://github.com/FIWARE/context.Orion-LD/issues/1374#issuecomment-1545831062, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AN5IJVKA6ZXGOKYNC2YL4LDXFZB5NANCNFSM6AAAAAAX7QE3LI. You are receiving this because you authored the thread.Message ID: @.***>