Is WAL_DEBUG related code still relevant today? - Mailing list pgsql-hackers
From | Bharath Rupireddy |
---|---|
Subject | Is WAL_DEBUG related code still relevant today? |
Date | |
Msg-id | CALj2ACVF14WKQMFwcJ=3okVDhiXpuK5f7YdT+BdYXbbypMHqWA@mail.gmail.com Whole thread Raw |
Responses |
Re: Is WAL_DEBUG related code still relevant today?
Re: Is WAL_DEBUG related code still relevant today? |
List | pgsql-hackers |
Hi, I was recently looking at the code around the WAL_DEBUG macro and GUC. When enabled, the code does the following: 1. Creates a memory context that allows pallocs within critical sections. 2. Decodes (not logical decoding but DecodeXLogRecord()) every WAL record using the above memory context that's generated in the server and emits a LOG message. 3. Emits messages at DEBUG level in AdvanceXLInsertBuffer(), at LOG level in XLogFlush(), at LOG level in XLogBackgroundFlush(). 4. Emits messages at LOG level for every record that the server replays/applies in the main redo loop. I enabled this code by compiling with the WAL_DEBUG macro and setting wal_debug GUC to on. Firstly, the compilation on Windows failed because XL_ROUTINE was passed inappropriately for XLogReaderAllocate() used. After fixing the compilation issue [1], the TAP tests started to fail [2] which I'm sure we can fix. I started to think if this code is needed at all in production. How about we do either of the following? a) Remove the WAL_DEBUG macro and move all the code under the wal_debug GUC? Since the GUC is already marked as DEVELOPER_OPTION, the users will know the consequences of enabling it in production. b) Remove both the WAL_DEBUG macro and the wal_debug GUC. I don't think (2) is needed to be in core especially when tools like pg_walinspect and pg_waldump can do the same job. And, the messages in (3) and (4) can be turned to some DEBUGX level without being under the WAL_DEBUG macro. I have no idea if anyone uses WAL_DEBUG macro and wal_debug GUCs in production, if we have somebody using it, I think we need to fix the compilation and test failure issues, and start testing this code (perhaps I can think of setting up a buildfarm member to help here). I'm in favour of option (b), but I'd like to hear more thoughts on this. [1] diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index ca7100d4db..52633793d4 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -1023,8 +1023,12 @@ XLogInsertRecord(XLogRecData *rdata, palloc(DecodeXLogRecordRequiredSpace(record->xl_tot_len)); if (!debug_reader) - debug_reader = XLogReaderAllocate(wal_segment_size, NULL, - XL_ROUTINE(), NULL); + debug_reader = XLogReaderAllocate(wal_segment_size, + NULL, + XL_ROUTINE(.page_read = NULL, + .segment_open = NULL, + .segment_close = NULL), + NULL); [2] src/test/subscription/t/029_on_error.pl because the test gets LSN from an error context message emitted to server logs which the new WAL_DEBUG LOG messages flood the server logs with. src/bin/initdb/t/001_initdb.pl because the WAL_DEBUG LOG messages are emitted to the console while initdb. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com
pgsql-hackers by date: