| From: | ocean_li_996 <ocean_li_996(at)163(dot)com> |
|---|---|
| To: | "Yuefei Shi" <shiyuefei1004(at)gmail(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, "mohen(dot)lhy(at)alibaba-inc(dot)com" <mohen(dot)lhy(at)alibaba-inc(dot)com> |
| Subject: | Re: minor improvement in snapbuild: use existing interface and remove fake code |
| Date: | 2025-11-18 02:05:18 |
| Message-ID: | 6b20d0d0.1c81.19a94b59251.Coremail.ocean_li_996@163.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi yuefei,
Thanks for your review.
At 2025-11-18 09:13:12, "Yuefei Shi" <shiyuefei1004(at)gmail(dot)com> wrote:
> - /* only build a new snapshot if we don't have a prebuilt one */
> - if (builder->snapshot == NULL)
> - {
> - builder->snapshot = SnapBuildBuildSnapshot(builder);
> - /* increase refcount for the snapshot builder */
> - SnapBuildSnapIncRefcount(builder->snapshot);
> - }
> + Snapshot snapshot = SnapBuildGetOrBuildSnapshot(builder);
>
> /*
> * Increase refcount for the transaction we're handing the snapshot
> * out to.
> */
> - SnapBuildSnapIncRefcount(builder->snapshot);
> + SnapBuildSnapIncRefcount(snapshot);
> ReorderBufferSetBaseSnapshot(builder->reorder, xid, lsn,
> - builder->snapshot);
> + snapshot);
>
> The snapshot created above is a temporary variable and is not recorded into builder->snapshot, which may cause a leak.
AFAICT, the snapshot is created and recorded into builder->snapshot in SnapBuildGetOrBuildSnapshot() if needed. And the local variable snapshot
is just a poniter which actually pointing to builder->snapshot. Did I missed something?
Regards,
Haiyang Li
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2025-11-18 02:25:38 | Re: postgresql.conf.sample tab width |
| Previous Message | Masahiko Sawada | 2025-11-18 02:03:26 | Re: postgres_fdw: Use COPY to speed up batch inserts |