chirpstack/api/rust
Orne Brocaar 098f8db4c6 Migrate device-sessions from Redis to PostgreSQL.
This migrates the device-sessions from Redis into PostgreSQL. This fixes
a performance issue in case the same DevAddr is reused many times
(e.g. devices rejoining very often or a NetID with small DevAddr space).

There were two issues:

The Redis key containing the DevAddr -> DevEUIs mapping could contain
DevEUIs that no longer used the DevAddr. This mapping would only expire
from the Redis database after none of the devices would use the DevAddr
for more than the configured device_session_ttl.

The other issue with the previous approach was that on for example a
Type 7 NetID, a single DevAddr could be re-used multiple times. As each
device-session could be stored on a different Redis Cluster instance,
there was no option to retrieve all device-sessions at once. Thus a high
re-usage of a single DevAddr would cause an increase in Redis queries.

Both issues are solved by moving the device-session into PostgreSQL
as the DevAddr is a column of the device record and thus filtering on
this DevAddr would always result in the devices using that DevAddr, as
well all device-sessions for a DevAddr can be retrieved by a single
query.

Note that to migrate the device-sessions, you must run:

chirpstack -c path/to/config migrate-device-sessions-to-postgres

A nice side-effect is that a PostgreSQL backup / restore will also
restore the device connectivity.

Closes  and .
2024-02-27 16:17:15 +00:00
..
proto Migrate device-sessions from Redis to PostgreSQL. 2024-02-27 16:17:15 +00:00
src Migrate device-sessions from Redis to PostgreSQL. 2024-02-27 16:17:15 +00:00
build.rs Migrate device-sessions from Redis to PostgreSQL. 2024-02-27 16:17:15 +00:00
Cargo.lock Bump version to 4.7.0-test.3 2024-01-12 09:19:50 +00:00
Cargo.toml Migrate device-sessions from Redis to PostgreSQL. 2024-02-27 16:17:15 +00:00
Makefile Update Makefiles. 2022-04-29 11:13:57 +01:00