Skip to content

Commit

Permalink
fix(data): add codes to remove db index of reading:deviceName:resourc…
Browse files Browse the repository at this point in the history
…eName when deleting readings

When adding readings, a redis sorted set will be created as db index for
the relation of reading:deviceName:resourceName, and this index will be
used to query readings by deviceName and resourceName.

However, the current implementation doesn't remove such index when an
associated event is deleted, thus generating incorrect query result for
readings.

This commit fixes this bug by adding codes to remove db index of
reading:deviceName:resourceName while deleting readings.

closes edgexfoundry#3774

Signed-off-by: Jude Hung <[email protected]>
  • Loading branch information
judehung committed Oct 25, 2021
1 parent d840d96 commit 173b095
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions internal/pkg/infrastructure/redis/reading.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (c *Client) asyncDeleteReadingsByIds(readingIds []string) {
_ = conn.Send(ZREM, ReadingsCollectionOrigin, storedKey)
_ = conn.Send(ZREM, CreateKey(ReadingsCollectionDeviceName, r.DeviceName), storedKey)
_ = conn.Send(ZREM, CreateKey(ReadingsCollectionResourceName, r.ResourceName), storedKey)
_ = conn.Send(ZREM, CreateKey(ReadingsCollectionDeviceNameResourceName, r.DeviceName, r.ResourceName), storedKey)
queriesInQueue++

if queriesInQueue >= c.BatchSize {
Expand Down

0 comments on commit 173b095

Please sign in to comment.