On Fri, Jan 15, 2016 at 2:16 PM, Tom Lane <t...@sss.pgh.pa.us> wrote: > Robert Haas <robertmh...@gmail.com> writes: >> Now, I do think it's a somewhat fair complaint that if you have a >> tablespace which is totally, 100% full, recovery is difficult. You >> can probably DROP the table, but TRUNCATE might fail, and so might >> VACUUM. You could argue that DROP is usually a good substitute for >> TRUNCATE, although there could be dependencies, but DROP is certainly >> not a good substitute for VACUUM. We could address the VACUUM case by >> having an optional argument to VACUUM which tells it to skip VM and >> FSM maintenance, presumably to be used only in case of emergency. I'm >> not sure if it's worth having for what is presumably a pretty rare >> case, but it seems like it could be done. > > Presumably the hope would be that VACUUM would truncate off some of the > heap, else there's not much good that's going to happen. That leaves > me wondering exactly what the invariant is for the maps, and if it's > okay to not touch them during a heap truncation.
No, you're missing the point, or at least I think you are. Suppose somebody creates a big table and then deletes all the tuples in the second half, but VACUUM never runs. When at last VACUUM does run on that table, it will try to build the VM and FSM forks as it scans the table, and will only truncate AFTER that has been done. If building the VM and FSM forks fails because there is no freespace, we will never reach the part of the operation that could create some. The key point is that both the VM and the FSM are optional. If there's no VM, vacuum will have to visit every page in the table and index-only scans will never be index-only, but everything still works. If there's no FSM, we'll assume the table has no internal freespace, so inserts will extend the table. Those consequences are bad, of course, so we really want vacuum to succeed in creating the VM and FSM. However, when a failure creating the FSM or VM causes us not to reach the truncation step, then there's no way to shrink the table. That's not good. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (firstname.lastname@example.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers