Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] MVCCAdapter.load: Raise ReadConflictError only if pack is running simultaneously #322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Jul 31, 2020

  1. MVCCAdapter.load: Raise ReadConflictError only if pack is running sim…

    …ultaneously
    
    Currently when load(oid) finds that the object was deleted, it raises
    ReadConflictError - not POSKeyError - because a pack could be running
    simultaneously and the deletion could result from the pack. In that case
    we want corresponding transaction to be retried - not failed - via
    raising ConflictError subclass for backward-compatibility reason.
    However from semantic point of view, it is more logically correct to
    raise POSKeyError, when an object is found to be deleted or
    not-yet-created, and raise ReadConflictError only if a pack was actually
    running simultaneously, and the deletion could result from that pack.
    
    -> Fix MVCCAdapter.load to do this - now it raises ReadConflictError
    only if MVCCAdapterInstance view appears before storage packtime, which
    indicates that there could indeed be conflict in between read access and
    pack removing the object.
    
    To detect if pack was running and beyond MVCCAdapterInstance view, we
    need to teach storage drivers to provide way to known what was the last
    pack time/transaction. Add optional IStorageLastPack interface with
    .lastPack() method to do so. If a storage does not implement lastPack,
    we take conservative approach and raise ReadConflictError
    unconditionally as before.
    
    Add/adapt corresponding tests.
    
    Teach FileStorage, MappingStorage and DemoStorage to implement the new
    interface.
    
    NOTE: storages that implement IMVCCStorage natively already raise
    POSKeyError - not ReadConflictError - when load(oid) finds deleted
    object. This is so because IMVCCStorages natively provide isolation, via
    e.g. RDBMS in case of RelStorage. The isolation property provided by
    RDBMS guarantees that connection view of the database is not affected by
    other changes - e.g. pack - until connection's transaction is complete.
    
    /cc @jimfulton
    navytux committed Jul 31, 2020
    Configuration menu
    Copy the full SHA
    ddfe57e View commit details
    Browse the repository at this point in the history