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 — Datastore transactions don't provide read-after-write semantics · Issue #1134 · googleapis/google-cloud-java

Datastore transactions don't provide read-after-write semantics #1134

New issue
Copy link
New issue
Copy link
Closed
Closed
Datastore transactions don't provide read-after-write semantics#1134
Copy link
Assignees
mziccard

Description

@jdimond
jdimond
opened on Aug 1, 2016
Issue body actions

Here is a simple repro to demonstrate the issue. Reads in transactions will not reflect writes from the same transaction:

// 1. Setup
Datastore datastore = ...
KeyFactory keyFactory = datastore.newKeyFactory().kind("test");
Key key = keyFactory.newKey(1);

// 1. Set initial value of entity to "old"
datastore.put(Entity.builder(keyFactory.newKey(1)).set("value", "old").build());

// 2. Start transaction and make sure value is "old"
Transaction transaction = datastore.newTransaction();
Entity entity1 = transaction.get(key);
if (!entity1.getString("value").equals("old")) {
  throw new IllegalStateException("Unexpected value");
}

// 3. Write "new" value
transaction.put(Entity.builder(entity1).set("value", "new").build());

// 4. Read entity again, value is still "old"
Entity entity2 = transaction.get(key);
if (!entity2.getString("value").equals("new")) {
  throw new IllegalStateException("Unexpected value"); // throws here
}

AFAIK Datastore v1beta3 makes this explicit by forcing all writes into the commit, making it impossible to read after a write. This behavior should also be reflected in the Java API, perhaps by throwing if there is a read attempt after a write.

Activity

  1. mziccard commented on Aug 8, 2016

    @mziccard
    mziccard
    on Aug 8, 2016
    Contributor
    More actions

    Hi @jdimond, thanks for the report!

    I am not sure we should throw here or rather document what's going on. @aozarov thoughts?

  2. aozarov commented on Aug 8, 2016

    @aozarov
    aozarov
    on Aug 8, 2016
    Contributor
    More actions

    I think this is already documented.
    I don't think we should throw an exception in this case.

  3. jdimond commented on Aug 8, 2016

    @jdimond
    jdimond
    on Aug 8, 2016
    Author
    More actions

    I think this goes beyond documenting (since I also believe most devs only read documentations when they run into errors). It is non-obvious that transactions don't have read-after-write semantics, and developers might run into this without noticing, which seems very dangerous given the nature of transactions. If they are running into this exception they will be made aware of the limitations of Datastore transactions and can decide whether they are fine with missing read-after-write semantics by working around the no reads after writes (similar to what the SDK does automatically today).

  4. aozarov commented on Aug 8, 2016

    @aozarov
    aozarov
    on Aug 8, 2016
    Contributor
    More actions

    Note that this is the same for App Engine Datastore API and documentation seemed to be sufficient.

  5. mziccard commented on Sep 6, 2016

    @mziccard
    mziccard
    on Sep 6, 2016
    Contributor
    More actions

    I am closing this as documentation seems sufficient in this case.

  6. mziccard
    closed this as completedon Sep 6, 2016
  7. JustinBeckwith
    assigned
    mziccard
    on Feb 1, 2021
  8. meltsufin
    added a commit that references this issue on Dec 22, 2025

    chore(main): release 3.11.8-SNAPSHOT (#1134)

    3df013a
  9. chingor13
    added a commit that references this issue on Jan 6, 2026

    chore(main): release 0.130.19-alpha-SNAPSHOT (#1134)

    e0beb73
  10. chingor13
    added a commit that references this issue on Jan 22, 2026

    chore(deps): update dependency com.google.cloud:libraries-bom to v26.…

    83a0018
  11. chingor13
    added a commit that references this issue on Feb 24, 2026

    feat: Introduce a way to pass additional parameters to auhtorization …

    3a2c5d3
  12. suztomo
    added a commit that references this issue on Mar 11, 2026

    chore(main): release 3.11.8-SNAPSHOT (googleapis#1134)

    c5937b7
  13. chingor13
    added a commit that references this issue on Mar 12, 2026

    feat: Introduce a way to pass additional parameters to auhtorization …

    238a8e4
  14. suztomo
    added a commit that references this issue on Mar 23, 2026

    chore(main): release 2.9.6 (googleapis#1134)

    e39a310
  15. meltsufin
    added 2 commits that reference this issue on Apr 29, 2026

    samples: pubsub_publisher_with_compression (#1134)

    01b3a60

    samples: pubsub_publisher_with_compression (#1134)

    a7fbcba
  16. benjaminp
    added a commit that references this issue on Jul 13, 2026

    build(deps): update dependency com.google.cloud:google-cloud-shared-c…

    9e7b529
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @mziccard
    mziccard

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    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.