[suggestion] Better logging of errors

Hello,
would be possible to review a text of the error (warning) messages written into the logs by adding database name? When we have multiple databases with TimescaleDB plugin it is bit complicated to find the problem. We have to check all DBs until we find a match between the job, hypertable and chunk.

Error/warning example

2025-05-04 06:54:59.727 CEST [1286510-1] @ 6816f31b.13a16e 54000WARNING: compressing chunk “_timescaledb_internal._hyper_65_2794_chunk” failed when compression policy is executed
2025-05-04 06:54:59.727 CEST [1286510-2] @ 6816f31b.13a16e 54000DETAIL: Message: (index row size 2808 exceeds btree version 4 maximum 2704 for index “compress_hyper_66_2870_chunk_dbname__ts_meta_min_1__ts_meta_idx”), Detail: (Index row references tuple (4,40) in relation “compress_hyper_66_2870_chunk”.).
2025-05-04 06:54:59.727 CEST [1286510-3] @ 6816f31b.13a16e 54000CONTEXT: PL/pgSQL function _timescaledb_functions.policy_compression_execute(integer,integer,anyelement,integer,boolean,boolean,boolean,boolean) line 72 at RAISE
SQL statement “CALL _timescaledb_functions.policy_compression_execute(
job_id, htid, lag_value::INTERVAL,
maxchunks, verbose_log, recompress_enabled, use_creation_time, hypercore_use_access_method
)”
PL/pgSQL function _timescaledb_functions.policy_compression(integer,jsonb) line 63 at CALL
2025-05-04 06:54:59.734 CEST [1286510-4] @ 6816f31b.13a16e 00000LOG: job 1032 threw an error
2025-05-04 06:54:59.734 CEST [1286510-5] @ 6816f31b.13a16e P0001ERROR: compression policy failure
2025-05-04 06:54:59.734 CEST [1286510-6] @ 6816f31b.13a16e P0001DETAIL: Failed to compress ‘1’ chunks. Successfully compressed ‘1’ chunks.
2025-05-04 06:54:59.734 CEST [1286510-7] @ 6816f31b.13a16e P0001CONTEXT: PL/pgSQL function _timescaledb_functions.policy_compression_execute(integer,integer,anyelement,integer,boolean,boolean,boolean,boolean) line 120 at RAISE
SQL statement “CALL _timescaledb_functions.policy_compression_execute(
job_id, htid, lag_value::INTERVAL,
maxchunks, verbose_log, recompress_enabled, use_creation_time, hypercore_use_access_method
)”
PL/pgSQL function _timescaledb_functions.policy_compression(integer,jsonb) line 63 at CALL

Great point @tester. I recommend creating an issue in the official github.

We may even have a way to configure the logger function to include details we want.