From 6e01b8c58166faf4eafe84935722b7d3c499e03f Mon Sep 17 00:00:00 2001 From: Nikhil Sontakke Date: Wed, 26 Jun 2024 14:46:34 +0530 Subject: [PATCH] Add logs in the recompression code path We added a few diagnostic log messages in the compression/decompression code paths some time ago and they have been useful in identifying hotspots in the actual activities. Adding a few more for recompression now. The row_compressor_append_sorted_rows function which is also used in recompression is already logged so we need just a few log messages here. --- tsl/src/compression/api.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tsl/src/compression/api.c b/tsl/src/compression/api.c index a0b62e0e3..a305757cc 100644 --- a/tsl/src/compression/api.c +++ b/tsl/src/compression/api.c @@ -1088,9 +1088,17 @@ recompress_chunk_segmentwise_impl(Chunk *uncompressed_chunk) * on the updated tuple in the CHUNK table potentially preventing other transaction * from updating it */ - ts_chunk_clear_status(uncompressed_chunk, - CHUNK_STATUS_COMPRESSED_UNORDERED | CHUNK_STATUS_COMPRESSED_PARTIAL); + if (ts_chunk_clear_status(uncompressed_chunk, + CHUNK_STATUS_COMPRESSED_UNORDERED | CHUNK_STATUS_COMPRESSED_PARTIAL)) + ereport(LOG, + (errmsg("cleared chunk status for recompression: \"%s.%s\"", + NameStr(uncompressed_chunk->fd.schema_name), + NameStr(uncompressed_chunk->fd.table_name)))); + ereport(LOG, + (errmsg("acquiring locks for recompression: \"%s.%s\"", + NameStr(uncompressed_chunk->fd.schema_name), + NameStr(uncompressed_chunk->fd.table_name)))); /* lock both chunks, compressed and uncompressed */ /* TODO: Take RowExclusive locks instead of AccessExclusive */ Relation uncompressed_chunk_rel = table_open(uncompressed_chunk->table_id, ExclusiveLock); @@ -1190,6 +1198,10 @@ recompress_chunk_segmentwise_impl(Chunk *uncompressed_chunk) /* Index scan */ Relation index_rel = index_open(row_compressor.index_oid, ExclusiveLock); + ereport(LOG, + (errmsg("locks acquired for recompression: \"%s.%s\"", + NameStr(uncompressed_chunk->fd.schema_name), + NameStr(uncompressed_chunk->fd.table_name)))); index_scan = index_beginscan(compressed_chunk_rel, index_rel, snapshot, 0, 0); TupleTableSlot *slot = table_slot_create(compressed_chunk_rel, NULL);