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

q Field Updates correctly when updating subscription, but notification still triggers on old condition. #1648

Open
SystemsPurge opened this issue Jul 24, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@SystemsPurge
Copy link

Steps:
Post an entity
Post a subscription with a condition ( e.g q = temperature<30 )
Update the entity to correspond to the condition
Update subscription to other condition (e.g q = temperature > 30 )
Update entity to correspond to new condition
Update entity to correspond to old condition again

What happens:
Notification is received on the first and third entity update but not the second one, despite the fact that on mongo express, the subscription is showing the correct expression

Here is the bash script i used to test it out :
`#!/bin/bash

#Post Entity
curl -X POST http://localhost:1026/ngsi-ld/v1/entities --header 'Content-Type:application/json' --data '{"id":"urn:ngsi-ld:Entity:test_entity03","type":"Room","temperature":{"type":"Property","value":29}}'
#Post Subscription
curl -X POST --url 'http://localhost:1026/ngsi-ld/v1/subscriptions' --header 'Content-Type: application/json' --data '{"description":"TestSubscription","id":"urn:ngsi-ld:Subscription:test_sub25","type":"Subscription","entities":[{"idPattern":".*","type":"Room"}],"watchedAttributes":["temperature"],"q":"temperature>30","notification":{"attributes":["temperature"],"format":"normalized","endpoint":{"uri":"mqtt://mosquitto:1883/my/test/topic"}}}'
#Update Entity
sleep 5
curl -iX PATCH --url 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Entity:test_entity03/attrs' --header 'Content-Type: application/json' --data-raw '{"temperature":{"type":"Property","value":35}}'
#Update Subscription
curl -iX PATCH --url 'http://localhost:1026/ngsi-ld/v1/subscriptions/urn:ngsi-ld:Subscription:test_sub25' --header 'Content-Type: application/json' --data-raw '{"q":"temperature<30"}'
#Update entity
sleep 5
curl -iX PATCH --url 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Entity:test_entity03/attrs' --header 'Content-Type: application/json' --data-raw '{"temperature":{"type":"Property","value":24}}'
sleep 5
curl -iX PATCH --url 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Entity:test_entity03/attrs' --header 'Content-Type: application/json' --data-raw '{"temperature":{"type":"Property","value":35}}'
`

@kzangeli kzangeli self-assigned this Aug 30, 2024
@kzangeli kzangeli added the bug Something isn't working label Aug 30, 2024
@kzangeli
Copy link
Collaborator

Seems like a bug in the subscription cache, not updating 'q' correctly.
I'm on it. Just, on a business trip all next week.
I'll do my best.

As a workaround, try PATCH http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Entity:test_entity03 instead of the one ending in /attrs (the one you use replaces the attribute, it's really a PUT, not a PATCH, while the one I propose is a proper PATCH).

What CLI params do you use when starting Orion-LD ?

@kzangeli
Copy link
Collaborator

Nah, idiot proposal (removing /attrs from the URL path of the entity patch request), the bug is in t he PATCH of the subscription.
I just tested both and the bug is (wrong q in sub-cache after subscription patch) there for noth versions of PATCH Entity.
So, scratch that.

@SystemsPurge
Copy link
Author

@kzangeli To answer the question about the CLI params , its a docker image ( in a compose file ) with the following env vars and command:
environment:
- ORIONLD_NOCACHE=FALSE
- ORIONLD_MULTI_SERVICE=FALSE
- ORIONLD_MONGO_DB=orionld
command: ["-dbhost", "mongo", "-logLevel", "DEBUG"]

@kzangeli
Copy link
Collaborator

kzangeli commented Sep 3, 2024

Still working on this.
Found a solution though, long story, try adding the option -experimental.
The entire DB layer has been reimplemented, using a newer mongo driver.
I tried it and it seems to be working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants