GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DISCUSSION: Is there a way for a Transaction to indicate success/failure from __exit__ · Issue #496 · googleapis/google-cloud-python

DISCUSSION: Is there a way for a Transaction to indicate success/failure from __exit__ #496

New issue
Copy link
New issue
Copy link
Closed
#595
Closed
DISCUSSION: Is there a way for a Transaction to indicate success/failure from __exit__#496
#595
Copy link
Assignees
dhermes
Labels
api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.
Milestone
Datastore Future

Description

@dhermes
dhermes
opened on Jan 7, 2015
Issue body actions

From #336.

Currently, there is no way to determine if this occurs. It's unclear what a way forward would look like but in ndb transactions have retries and can create Future objects which know about the success or failure.

Activity

Next
  1. dhermes
    added
    type: questionRequest for information or clarification. Not an issue.
    api: datastoreIssues related to the Datastore API.
    on Jan 7, 2015
  2. tseaver commented on Jan 7, 2015

    @tseaver
    tseaver
    on Jan 7, 2015
    Contributor
    More actions

    The transaction package has a concept of a "doomed" transaction: one which is in a hosed state, from which it can never be committed. Having our code fail inside __exit__ would be something like that with two sharp edges:

    • Failing while committing is actually more reasonable: the back-end might actually barf here.
    • Failing while aborting is a real problem: which exception should surface?

    FWIW, the Zope transaction's "two-phase commit" tries to deal with the problems of the first, by breaking up the "commit" into slices, for distribution across multiple resource managers (e.g., a database and a mail-sender). For each of the following methods, the transaction calls each resource manager in turn):

    • tpc_begin (can we commit?)
    • commit(do the work, but don't finalize)
    • tpc_vote (were there problems? last chance to back out)
    • tpc_finish (finalize; this must never fail: if it does, we've lost consistency)
    • tpc_abort (called if any RM raises from tpc_vote: must never fail).
  3. dhermes commented on Jan 8, 2015

    @dhermes
    dhermes
    on Jan 8, 2015
    ContributorAuthor
    More actions

    For the most part the backend handles this.

    It seems a concept of "doomed" would be nice since it would make it so that.

    txn = Transaction()
    with txn:
        entity.save()
        ...
    
    # This fails since txn has already been used, hence is doomed.
    with txn:
        new_entity.save()

    I was thinking something simple along the lines of

    >>> txn.in_progress
    False
    >>> txn.succeeded
    True
    >>> txn.finished
    True

    There seem to be less than 8 states (implied by 3 bools) but more than 4, so maybe there is a better way to get the information to answer the questions:

    • txn is in progress or not?
    • txn has already been "used"?
    • txn finished in commit (success) or rollback (failure)
  4. elibixby commented on Jan 8, 2015

    @elibixby
    elibixby
    on Jan 8, 2015
    More actions

    You also need some way to get auto allocated keys back from the transaction right? Could this be incorporated into the method which indicates failure or success?

  5. jgeewax
    modified the milestones: This milestone has been deleted, Datastore Future on Feb 2, 2015
  6. dhermes
    self-assigned this
    on Feb 5, 2015
  7. dhermes
    added 2 commits that reference this issue on Feb 5, 2015

    Tracking status of Transaction as well as success / failure.

    This issue will close once commit 63265b0 is merged into the 'master' branch.
    63265b0

    Tracking status of Transaction as well as success / failure.

    This issue will close once commit 52f3fa8 is merged into the 'master' branch.
    52f3fa8
  8. dhermes
    closed this as completedin #595on Feb 6, 2015
  9. tswast
    added a commit that references this issue on Apr 1, 2019

    Drop Python 3.4. (googleapis#496)

    64fee9b
  10. atulep
    added a commit that references this issue on Apr 6, 2023

    build(deps): bump cryptography from 38.0.3 to 39.0.1 in /synthtool/gc…

    e965415
  11. 10 remaining items

  12. parthea
    added a commit that references this issue on Oct 22, 2023

    build(deps): bump cryptography from 38.0.3 to 39.0.1 in /synthtool/gc…

    242bd0e
  13. parthea
    added a commit that references this issue on Sep 18, 2025

    chore(main): release 0.17.3 (#496)

    dd94a4e
  14. parthea
    added 9 commits that reference this issue on Nov 24, 2025

    feat: support quota project override via client options (#496)

    b607c1f

    feat: migrate to pyproject.toml (#496)

    702eb82

    chore: bump urllib3 from 1.26.12 to 1.26.18 (#496)

    c1fd009

    docs: add summary_overview template (#496)

    4024708

    feat: allow 'Collection.where(__name__, in, [hello, world])' (#501)

    b95ed9a

    chore: Adding support for pytest-xdist and pytest-parallel (#496)

    a0a3dba

    fix: fix concurrency bug in redis cache implementation (#503)

    904e6c8

    chore: Adding support for pytest-xdist and pytest-parallel (#496)

    ea16b77

    feat: encrypted mtls private key support (#496)

    4c55ce6
  15. parthea
    added 2 commits that reference this issue on Mar 2, 2026

    chore(deps): update dependency google-cloud-pubsub to v2.8.0 (#496)

    ed9a97d

    chore: Migrate gsutil usage to gcloud storage (#496)

    85b84bc
  16. parthea
    added 2 commits that reference this issue on Mar 9, 2026

    feat: support Partitioned DML (#541)

    This issue will close once commit 6e461e6 is merged into the 'main' branch.
    6e461e6

    fix(deps): update minimum dependency versions to pick up bugfixes (#496)

    This issue will close once commit 533bdf2 is merged into the 'main' branch.
    533bdf2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dhermes
    dhermes

Labels

api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    • Datastore Future

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.