Migration to TimescaleDB solved this problem. At least it doesn't occur now .
At first I thought that the problem was caused by duplicate data (see https://www.netxms.org/forum/general-support/migration-from-postgresql-to-timescaledb-failed/), but even after deleting duplicate data, the problem occurs with the old PostgreSQL database, but not with data migrated to TimescaleDB.
At first I thought that the problem was caused by duplicate data (see https://www.netxms.org/forum/general-support/migration-from-postgresql-to-timescaledb-failed/), but even after deleting duplicate data, the problem occurs with the old PostgreSQL database, but not with data migrated to TimescaleDB.