l.s.l.DBLoopTuner(LoopTuner) : class documentation

Part of lp.services.looptuner View In Hierarchy

A LoopTuner that plays well with PostgreSQL and replication.

This LoopTuner blocks when database replication is lagging. Making updates faster than replication can deal with them is counter productive and in extreme cases can put the database into a death spiral. So we don't do that.

This LoopTuner also blocks when there are long running transactions. Vacuuming is ineffective when there are long running transactions. We block when long running transactions have been detected, as it means we have already been bloating the database for some time and we shouldn't make it worse. Once the long running transactions have completed, we know the dead space we have already caused can be cleaned up so we can keep going.

INFO level messages are logged when the DBLoopTuner blocks in addition to the DEBUG level messages emitted by the standard LoopTuner.

Method _blockWhenLagged When database replication lag is high, block until it drops.
Method _blockForLongRunningTransactions If there are long running transactions, block to avoid making
Method _coolDown As per LoopTuner._coolDown, except we always wait until there

Inherited from LoopTuner:

Method __init__ Initialize a loop, to be run to completion at most once.
Method run Run the loop to completion.
Method _isTimedOut Return True if the task will be timed out in extra_seconds.
Method _time Monotonic system timer with unit of 1 second.
Method _sleep Sleep.
def _blockWhenLagged(self):
When database replication lag is high, block until it drops.
def _blockForLongRunningTransactions(self):
If there are long running transactions, block to avoid making bloat worse.
def _coolDown(self, bedtime):
As per LoopTuner._coolDown, except we always wait until there is no replication lag.
API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.