Search code examples
transactionsfirebirdfirebird2.5

Firebird DB read deleted register after commit


I have a firebird 2.5 database, and I was wondering if there is a way to rollback a transaction that was commited. Really, I'm asking if someone who could access to firebird database file, can read data that was deleted in a prior commited transaction.
I have a process (stored procedure) that delete some registers and commit. Could this registers be recovery for someone who can access to the database file?


Solution

  • There is no simple way to recover/rollback committed transactions, however Firebird uses MVCC (Multi Version Concurrency Control). Deleting (or updating) a record will add a new record version and create a delta recordversion for the previous state of the record.

    When no transaction is 'interested' in the old record version, it becomes eligible for garbage collection (which might be done cooperatively when another transaction visits the record, or in the background). However there is no guarantee when this garbage collection occurs.

    So if a record is deleted, but hasn't been garbage collected yet (either because there are still transactions with an interest in it, or because the garbage collector hasn't visited the record yet), then it is still possible for people with sufficient skill and knowledge of the internal structure of Firebird to recover the record. Note that even if a record version has been garbage collected, the data itself will be on disk until it is overwritten by another record version.

    See also Firebird for the Database Expert: Episode 4 - OAT, OIT, & Sweep