Re: Avoiding unnecessary writes during relation drop and truncate

From: "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Avoiding unnecessary writes during relation drop and truncate
Date: 2005-03-21 02:11:15
Message-ID: d1laou$2r5m$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes
> It strikes me that the FlushRelationBuffers call is unnecessary and
> causes useless I/O, namely writing out pages into a file that's
> about to be deleted anyway. If we simply removed it then any buffers
> belonging to the victim relation would stay in memory until commit;
> then they'd be dropped *without* write by the smgr unlink operation
> (which already calls DropRelFileNodeBuffers).
>

In my understanding, DropRelFileNodeBuffers is done in post-commit stage.
The call sequences are:

...
AtEOXact_Inval(true);

smgrDoPendingDeletes(true);
...

What if AtEOXact_Inval() fails (though the chance is slim)? Does that mean
that smgrDoPendingDeletes() -> DropRelFileNodeBuffers can never get
executed, which means we can never "dropped without write" the buffers
belonging to the victim relation? So when the BgWrite sweeps, it will write
those buffers to a non-logically-existed file?

Regards,
Qingqing

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-03-21 02:54:20 Re: Avoiding unnecessary writes during relation drop and truncate
Previous Message Tom Lane 2005-03-21 01:36:01 Re: read-only planner input