Firebird Documentation IndexFirebird 2.0.6 Release NotesNew in Firebird 2.0 → Reworking of Garbage Collection
Firebird Home Firebird Home Prev: Reimplemented Protocols on WindowsFirebird Documentation IndexUp: New in Firebird 2.0Next: Porting of the Services API to Classic is Complete

Reworking of Garbage Collection

V. Horsun

Since Firebird 1.0 and earlier, the Superserver engine has performed background garbage collection, maintaining information about each new record version produced by an UPDATE or DELETE statement. As soon as the old versions are no longer “interesting”, i.e. when they become older than the Oldest Snapshot transaction (seen in the gstat -header output) the engine signals for them to be removed by the garbage collector.

Background GC eliminates the need to re-read the pages containing these versions via a SELECT COUNT(*) FROM aTable or other table-scanning query from a user, as occurs in Classic and in versions of InterBase prior to v.6.0. This earlier GC mechanism is known as cooperative garbage collection.

Background GC also averts the possibility that those pages will be missed because they are seldom read. (A sweep, of course, would find those unused record versions and clear them, but the next sweep is not necessarily going to happen soon.) A further benefit is the reduction in I/O, because of the higher probability that subsequently requested pages still reside in the buffer cache.

Between the point where the engine notifies the garbage collector about a page containing unused versions and the point when the garbage collector gets around to reading that page, a new transaction could update a record on it. The garbage collector cannot clean up this record if this later transaction number is higher than the Oldest Snapshot or is still active. The engine again notifies the garbage collector about this page number, overriding the earlier notification about it and the garbage will be cleaned at some later time.

In Firebird 2.0 Superserver, both cooperative and background garbage collection are now possible. To manage it, the new configuration parameter GCPolicy was introduced. It can be set to:

Note

The Classic server ignores this parameter and always works in “cooperative” mode.

Prev: Reimplemented Protocols on WindowsFirebird Documentation IndexUp: New in Firebird 2.0Next: Porting of the Services API to Classic is Complete
Firebird Documentation IndexFirebird 2.0.6 Release NotesNew in Firebird 2.0 → Reworking of Garbage Collection