Movatterモバイル変換


[0]ホーム

URL:


Quick Links

[BUG] Skipped initialization of some xl_xact_parsed_prepare fields

From:Daniil Davydov <3danissimo(at)gmail(dot)com>
To:PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject:[BUG] Skipped initialization of some xl_xact_parsed_prepare fields
Date:2025-05-15 05:39:38
Message-ID:CAJDiXgh-6Epb2XiJe4uL0zF-cf0_s_7Lw1TfEHDMLzYjEmfGOw@mail.gmail.com
Views:Whole Thread |Raw Message |Download mbox |Resend email
Thread:
Lists:pgsql-hackers

Hi,
I noticed that inside ParsePrepareRecord function we are missing
initialization of `nstats` and `nabortstats` fields of
xl_xact_parsed_prepare structure:
*** (current code in master)
memset(parsed, 0, sizeof(*parsed));

parsed->xact_time = xlrec->prepared_at;
parsed->origin_lsn = xlrec->origin_lsn;
parsed->origin_timestamp = xlrec->origin_timestamp;
parsed->twophase_xid = xlrec->xid;
parsed->dbId = xlrec->database;
parsed->nsubxacts = xlrec->nsubxacts;
parsed->nrels = xlrec->ncommitrels;
parsed->nabortrels = xlrec->nabortrels;
parsed->nmsgs = xlrec->ninvalmsgs;
***

Thus, they will always be 0 after calling the ParsePrepareRecord
function, but `stats` and `abortstats` pointers are set correctly:
*** (current code in master)
parsed->stats = (xl_xact_stats_item *) bufptr;
bufptr += MAXALIGN(xlrec->ncommitstats * sizeof(xl_xact_stats_item));

parsed->abortstats = (xl_xact_stats_item *) bufptr;
bufptr += MAXALIGN(xlrec->nabortstats * sizeof(xl_xact_stats_item));
***

If we look (for example) on parsing of a commit record, we could see
that both `nstats` and `stats` fields are set inside the
ParseCommitRecord function.
For now, zeroed number of stats lead to invalid output of
`xact_desc_prepare`, because it relies on values of `nstats` and
`nabortstats` fields:
*** (current code in master)
xact_desc_stats(buf, "commit ", parsed.nstats, parsed.stats);
xact_desc_stats(buf, "abort ", parsed.nabortstats, parsed.abortstats);
***

I suppose to add initialization of `nstats` and `nabortstats` to
ParsePrepareRecord (see attached patch).

--
Best regards,
Daniil Davydov

AttachmentContent-TypeSize
v1-0001-Add-initialization-of-nstats-and-nabortstats-fiel.patchtext/x-patch975 bytes

Responses

Browse pgsql-hackers by date

 FromDateSubject
Next MessagePavel Stehule2025-05-15 06:48:37Re: Re: proposal: schema variables
Previous Messagewenhui qiu2025-05-15 02:06:38Re: Should we optimize the `ORDER BY random() LIMIT x` case?

[8]ページ先頭

©2009-2025 Movatter.jp