xlogfilename

Started by 王刚over 8 years ago6 messages
#1王刚
computer_wg@163.com

I study source code about wal, and have a question about xlog file name . what does 000000010000000000000001 mean? Someone says that it means tli logid segno. I don't understand.

#2DEV_OPS
devops@ww-it.cn
In reply to: 王刚 (#1)
Re: xlogfilename

I think you may reference to function: pg_xlogfile_name in
src/backend/access/transam/xlogfuncs.c, it use XLogFileName defined in
src/include/access/xlog_internal.h

#define XLogFileName(fname, tli, logSegNo) \
snprintf(fname, MAXFNAMELEN, "%08X%08X%08X", tli, \
(uint32) ((logSegNo) / XLogSegmentsPerXLogId), \
(uint32) ((logSegNo) % XLogSegmentsPerXLogId))

hope it's helpful for you

--Tony

On 20/07/2017 16:42, 王刚 wrote:

I study source code about wal, and have a question about xlog file name . what does 000000010000000000000001 mean? Someone says that it means tli logid segno. I don't understand.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Michael Paquier
michael.paquier@gmail.com
In reply to: DEV_OPS (#2)
Re: xlogfilename

On Thu, Jul 20, 2017 at 10:58 AM, DEV_OPS <devops@ww-it.cn> wrote:

I think you may reference to function: pg_xlogfile_name in
src/backend/access/transam/xlogfuncs.c, it use XLogFileName defined in
src/include/access/xlog_internal.h

#define XLogFileName(fname, tli, logSegNo) \
snprintf(fname, MAXFNAMELEN, "%08X%08X%08X", tli, \
(uint32) ((logSegNo) / XLogSegmentsPerXLogId), \
(uint32) ((logSegNo) % XLogSegmentsPerXLogId))

hope it's helpful for you

The first 8 characters are the timeline number in hexadecimal format.
The next 8 characters indicate a segment number, which gets
incremented every 256 segments in hexa format. The last 8 characters
indicate the current segment number in hexa format.
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Yugo Nagata
nagata@sraoss.co.jp
In reply to: Michael Paquier (#3)
Re: xlogfilename

On Thu, 20 Jul 2017 11:02:25 +0200
Michael Paquier <michael.paquier@gmail.com> wrote:

On Thu, Jul 20, 2017 at 10:58 AM, DEV_OPS <devops@ww-it.cn> wrote:

I think you may reference to function: pg_xlogfile_name in
src/backend/access/transam/xlogfuncs.c, it use XLogFileName defined in
src/include/access/xlog_internal.h

#define XLogFileName(fname, tli, logSegNo) \
snprintf(fname, MAXFNAMELEN, "%08X%08X%08X", tli, \
(uint32) ((logSegNo) / XLogSegmentsPerXLogId), \
(uint32) ((logSegNo) % XLogSegmentsPerXLogId))

hope it's helpful for you

The first 8 characters are the timeline number in hexadecimal format.
The next 8 characters indicate a segment number, which gets
incremented every 256 segments in hexa format. The last 8 characters
indicate the current segment number in hexa format.

As far as I understand, XLOG is a logical big file of 256 * 16 MB,
and this is split to multiple physical files of 16MB which are called
WAL segments. The second 8 characters indicate the id of the logical
xlog file, and the last 8 characters indicate the sequencial number of
the segment in this xlog.

Regards,

--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

--
Yugo Nagata <nagata@sraoss.co.jp>

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5Craig Ringer
craig@2ndquadrant.com
In reply to: Yugo Nagata (#4)
Re: xlogfilename

On 20 July 2017 at 21:33, Yugo Nagata <nagata@sraoss.co.jp> wrote:

On Thu, 20 Jul 2017 11:02:25 +0200
Michael Paquier <michael.paquier@gmail.com> wrote:

On Thu, Jul 20, 2017 at 10:58 AM, DEV_OPS <devops@ww-it.cn> wrote:

I think you may reference to function: pg_xlogfile_name in
src/backend/access/transam/xlogfuncs.c, it use XLogFileName defined

in

src/include/access/xlog_internal.h

#define XLogFileName(fname, tli, logSegNo) \
snprintf(fname, MAXFNAMELEN, "%08X%08X%08X", tli, \
(uint32) ((logSegNo) / XLogSegmentsPerXLogId), \
(uint32) ((logSegNo) % XLogSegmentsPerXLogId))

hope it's helpful for you

The first 8 characters are the timeline number in hexadecimal format.
The next 8 characters indicate a segment number, which gets
incremented every 256 segments in hexa format. The last 8 characters
indicate the current segment number in hexa format.

As far as I understand, XLOG is a logical big file of 256 * 16 MB,
and this is split to multiple physical files of 16MB which are called
WAL segments. The second 8 characters indicate the id of the logical
xlog file, and the last 8 characters indicate the sequencial number of
the segment in this xlog.
<http://www.postgresql.org/mailpref/pgsql-hackers&gt;

You missed the timeline ID, which is the first 8 digits.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

#6Yugo Nagata
nagata@sraoss.co.jp
In reply to: Craig Ringer (#5)
Re: xlogfilename

On Fri, 21 Jul 2017 10:11:05 +0800
Craig Ringer <craig@2ndquadrant.com> wrote:

On 20 July 2017 at 21:33, Yugo Nagata <nagata@sraoss.co.jp> wrote:

On Thu, 20 Jul 2017 11:02:25 +0200
Michael Paquier <michael.paquier@gmail.com> wrote:

On Thu, Jul 20, 2017 at 10:58 AM, DEV_OPS <devops@ww-it.cn> wrote:

I think you may reference to function: pg_xlogfile_name in
src/backend/access/transam/xlogfuncs.c, it use XLogFileName defined

in

src/include/access/xlog_internal.h

#define XLogFileName(fname, tli, logSegNo) \
snprintf(fname, MAXFNAMELEN, "%08X%08X%08X", tli, \
(uint32) ((logSegNo) / XLogSegmentsPerXLogId), \
(uint32) ((logSegNo) % XLogSegmentsPerXLogId))

hope it's helpful for you

The first 8 characters are the timeline number in hexadecimal format.
The next 8 characters indicate a segment number, which gets
incremented every 256 segments in hexa format. The last 8 characters
indicate the current segment number in hexa format.

As far as I understand, XLOG is a logical big file of 256 * 16 MB,
and this is split to multiple physical files of 16MB which are called
WAL segments. The second 8 characters indicate the id of the logical
xlog file, and the last 8 characters indicate the sequencial number of
the segment in this xlog.
<http://www.postgresql.org/mailpref/pgsql-hackers&gt;

You missed the timeline ID, which is the first 8 digits.

Yes, I missed this. Thanks.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Yugo Nagata <nagata@sraoss.co.jp>

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers