| From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
|---|---|
| To: | Mihail Nikalayeu <mihailnikalayeu(at)gmail(dot)com> |
| Cc: | Antonin Houska <ah(at)cybertec(dot)at>, Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Robert Treat <rob(at)xzilla(dot)net> |
| Subject: | Re: Adding REPACK [concurrently] |
| Date: | 2026-04-06 22:22:32 |
| Message-ID: | 202604062213.cgo352cdsgsm@alvherre.pgsql |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello,
On 2026-Apr-06, Mihail Nikalayeu wrote:
> > Yeah but I don't want the virtual tuple to be materialized (which would
> > happen in tts_virtual_materialize if I set shouldFree=true). The memory
> > should be freed in
> > ResetPerTupleExprContext(chgcxt->cc_estate);
> > anyway, right? Maybe deserves a comment.
>
> Not sure, ResetPerTupleExprContext resets just "ExecutorState".
> But slots are created in another memory context.
>
> Also, we can't reset slot->tts_mcxt itself - it will free the slot also.
So what I ended up doing, is to just not change to the slot's context in
restore_tuple. That was just dumb (mea culpa). So all the memory we
allocate for the slot lives in the executor context, and goes away on
the ResetPerTupleExprContext call at the bottom of the loop. BTW I
don't understand why you say that function only resets ExecutorState --
as far as I can tell, it does this
#define ResetPerTupleExprContext(estate) \
do { \
if ((estate)->es_per_tuple_exprcontext) \
ResetExprContext((estate)->es_per_tuple_exprcontext); \
} while (0)
which in turn does
#define ResetExprContext(econtext) \
MemoryContextReset((econtext)->ecxt_per_tuple_memory)
which AFAICT is exactly what we want.
Anyway, here's the three missing parts. I have not yet edited the
deadlock-checker one to protect autovacuum from processing tables under
repack.
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
| Attachment | Content-Type | Size |
|---|---|---|
| v56-0001-Allow-logical-replication-snapshots-to-be-databa.patch | text/x-diff | 24.4 KB |
| v56-0002-Reserve-replication-slots-specifically-for-REPAC.patch | text/x-diff | 27.5 KB |
| v56-0003-Error-out-any-process-that-would-block-at-REPACK.patch | text/x-diff | 11.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zsolt Parragi | 2026-04-06 22:46:46 | Re: Stack-based tracking of per-node WAL/buffer usage |
| Previous Message | Jacob Champion | 2026-04-06 22:16:55 | Re: Custom oauth validator options |