Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9e4664d

Browse files
committed
Add a new 'F' entry type for fixed-numbered stats in pgstats file
This new entry type is used for all the fixed-numbered statistics,making possible support for custom pluggable stats. In short, we needto be able to detect more easily if a stats kind exists or not whenreading back its data from the pgstats file without a dependency on theorder of the entries read. The kind ID of the stats is added to thedata written.The data is written in the same fashion as previously, with thefixed-numbered stats first and the dshash entries next. The read partbecomes more flexible, loading fixed-numbered stats into shared memorybased on the new entry type found.Bump PGSTAT_FILE_FORMAT_ID.Reviewed-by: Bertrand DrouvotDiscussion:https://postgr.es/m/Zot5bxoPYdS7yaoy@paquier.xyz
1 parent21471f1 commit9e4664d

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

‎src/backend/utils/activity/pgstat.c

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
* ---------
133133
*/
134134
#definePGSTAT_FILE_ENTRY_END'E'/* end of file */
135+
#definePGSTAT_FILE_ENTRY_FIXED'F'/* fixed-numbered stats entry */
135136
#definePGSTAT_FILE_ENTRY_NAME'N'/* stats entry identified by name */
136137
#definePGSTAT_FILE_ENTRY_HASH'S'/* stats entry identified by
137138
* PgStat_HashKey */
@@ -1396,6 +1397,9 @@ pgstat_write_statsfile(void)
13961397

13971398
pgstat_build_snapshot_fixed(kind);
13981399
ptr= ((char*)&pgStatLocal.snapshot)+info->snapshot_ctl_off;
1400+
1401+
fputc(PGSTAT_FILE_ENTRY_FIXED,fpout);
1402+
write_chunk_s(fpout,&kind);
13991403
write_chunk(fpout,ptr,info->shared_data_len);
14001404
}
14011405

@@ -1537,32 +1541,43 @@ pgstat_read_statsfile(void)
15371541
format_id!=PGSTAT_FILE_FORMAT_ID)
15381542
gotoerror;
15391543

1540-
/* Read various stats structs with fixed number of objects */
1541-
for (intkind=PGSTAT_KIND_FIRST_VALID;kind <=PGSTAT_KIND_LAST;kind++)
1542-
{
1543-
char*ptr;
1544-
constPgStat_KindInfo*info=pgstat_get_kind_info(kind);
1545-
1546-
if (!info->fixed_amount)
1547-
continue;
1548-
1549-
Assert(info->shared_ctl_off!=0);
1550-
1551-
ptr= ((char*)shmem)+info->shared_ctl_off+info->shared_data_off;
1552-
if (!read_chunk(fpin,ptr,info->shared_data_len))
1553-
gotoerror;
1554-
}
1555-
15561544
/*
1557-
* We found an existing statistics file. Read it and put all thehash
1558-
*table entries into place.
1545+
* We found an existing statistics file. Read it and put all thestats
1546+
*data into place.
15591547
*/
15601548
for (;;)
15611549
{
15621550
intt=fgetc(fpin);
15631551

15641552
switch (t)
15651553
{
1554+
casePGSTAT_FILE_ENTRY_FIXED:
1555+
{
1556+
PgStat_Kindkind;
1557+
constPgStat_KindInfo*info;
1558+
char*ptr;
1559+
1560+
/* entry for fixed-numbered stats */
1561+
if (!read_chunk_s(fpin,&kind))
1562+
gotoerror;
1563+
1564+
if (!pgstat_is_kind_valid(kind))
1565+
gotoerror;
1566+
1567+
info=pgstat_get_kind_info(kind);
1568+
1569+
if (!info->fixed_amount)
1570+
gotoerror;
1571+
1572+
/* Load back stats into shared memory */
1573+
ptr= ((char*)shmem)+info->shared_ctl_off+
1574+
info->shared_data_off;
1575+
1576+
if (!read_chunk(fpin,ptr,info->shared_data_len))
1577+
gotoerror;
1578+
1579+
break;
1580+
}
15661581
casePGSTAT_FILE_ENTRY_HASH:
15671582
casePGSTAT_FILE_ENTRY_NAME:
15681583
{

‎src/include/pgstat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ typedef struct PgStat_TableXactStatus
235235
* ------------------------------------------------------------
236236
*/
237237

238-
#definePGSTAT_FILE_FORMAT_ID0x01A5BCAC
238+
#definePGSTAT_FILE_FORMAT_ID0x01A5BCAD
239239

240240
typedefstructPgStat_ArchiverStats
241241
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp