relstorage.adapters.packundo – Pack/Undo implementations

Pack/Undo implementations.

class HistoryFreePackUndo(database_driver, connmanager, runner, locker, options)[source]

Bases: relstorage.adapters.packundo.PackUndo

History-free pack/undo.

fill_object_refs(load_connection, store_connection, get_references)[source]

Update the object_refs table by analyzing new object states.

See pre_pack() for a description of the parameters.

Because load_connection is read-only and repeatable read, we don’t need to do any object-level locking.

on_fill_object_ref_batch(oid_batch, num_refs_found)[source]

Hook for testing.

pack(pack_tid, packed_func=None)[source]

Run garbage collection.

Requires the information provided by pre_pack.

pre_pack(pack_tid, get_references)[source]

Decide what the garbage collector should delete.

Objects created or modified after pack_tid will not be garbage collected.

get_references is a function that accepts a pickled state and returns a set of OIDs that state refers to.

The self.options.pack_gc flag indicates whether to run garbage collection. If pack_gc is false, this method does nothing.

undo(cursor, undo_tid, self_tid)[source]

Undo a transaction.

Parameters: “undo_tid”, the integer tid of the transaction to undo, and “self_tid”, the integer tid of the current transaction.

Returns the list of OIDs undone.

verify_undoable(cursor, undo_tid)[source]

Raise UndoError if it is not safe to undo the specified txn.

class HistoryPreservingPackUndo(database_driver, connmanager, runner, locker, options)[source]

Bases: relstorage.adapters.packundo.PackUndo

History-preserving pack/undo.

fill_object_refs(load_connection, store_connection, get_references)[source]

Update the object_refs table by analyzing new transactions.

pack(pack_tid, packed_func=None)[source]

Pack. Requires the information provided by pre_pack.

pre_pack(pack_tid, get_references)[source]

Decide what to pack.

pack_tid specifies the most recent transaction to pack.

get_references is a function that accepts a pickled state and returns a set of OIDs that state refers to.

The self.options.pack_gc flag indicates whether to run garbage collection. If pack_gc is false, at least one revision of every object is kept, even if nothing refers to it. Packing with pack_gc disabled can be much faster.

undo(cursor, undo_tid, self_tid)[source]

Undo a transaction.

Parameters: “undo_tid”, the integer tid of the transaction to undo, and “self_tid”, the integer tid of the current transaction.

Returns the states copied forward by the undo operation as a list of (oid, old_tid).

verify_undoable(cursor, undo_tid)[source]

Raise UndoError if it is not safe to undo the specified txn.

class PackUndo(database_driver, connmanager, runner, locker, options)[source]

Bases: relstorage.adapters._util.DatabaseHelpersMixin

Abstract base class for pack/undo

check_refs(pack_tid)[source]

Are there any objects we’re not going to garbage collect that point to an object that doesn’t exist? Note that this goes only one level deep. A whole subtree of objects may be removed by a subsequent pack if the only reference them was from a missing object.

Logs a warning for each discovered broken reference.

Returns a true object if there were broken references, a false object otherwise.

choose_pack_transaction(pack_point)[source]

Return the transaction before or at the specified pack time.

Returns None if there is nothing to pack.

on_filling_object_refs_added(oids=None, tids=None)[source]

Test injection point for packing.

with_options(options)[source]

Return a new instance that will use the given options, instead of the options originally constructed.