- 
                Notifications
    
You must be signed in to change notification settings  - Fork 67
 
Closed
Labels
🚨This issue needs some love.This issue needs some love.triage meI really want to be triaged.I really want to be triaged.
Description
I'm trying to achieve Strong Consistency in a query that is not inside a transaction and does not have a parent as described in https://cloud.google.com/datastore/docs/concepts/structuring_for_strong_consistency. However, I'm not sure if that is even possible, this issue is to clarify that.
Environment details
- OS type and version: macOS Catalina 10.15.2
 - Python version and virtual environment information: Python 3.7
 - google-cloud-cloud version: 1.0.1
 
Steps to reproduce
- Define a class with an 
IntegerPropertylike a counter. (I acknowledge this may be an antipattern according to Datastore.) - Queries that rely on getting the entity with the smallest/highest counter value aren't consistent.
 
Code example
class A(ndb.Model):
    i_counter = ndb.IntegerProperty()
# I was hopping something like this would work.
if __name__ == "__main__":
    foo = A.query().order(-A.i_counter).get(read_consistency=ndb.STRONG)Stack trace
Traceback (most recent call last):
  ...
  File "google/cloud/ndb/query.py", line 1236, in wrapper
    return wrapped(self, *dummy_args, _options=query_options)
  File "google/cloud/ndb/utils.py", line 78, in wrapper
    return wrapped(*args, **new_kwargs)
  File "google/cloud/ndb/utils.py", line 110, in positional_wrapper
    return wrapped(*args, **kwds)
  File "google/cloud/ndb/query.py", line 2110, in get
    return self.get_async(_options=kwargs["_options"]).result()
  File "google/cloud/ndb/tasklets.py", line 190, in result
    self.check_success()
  File "google/cloud/ndb/tasklets.py", line 137, in check_success
    raise self._exception
  File "google/cloud/ndb/tasklets.py", line 309, in _advance_tasklet
    self.generator.throw(type(error), error, traceback)
  File "google/cloud/ndb/query.py", line 2144, in get_async
    results = yield _datastore_query.fetch(options)
  File "google/cloud/ndb/tasklets.py", line 309, in _advance_tasklet
    self.generator.throw(type(error), error, traceback)
  File "google/cloud/ndb/_datastore_query.py", line 105, in fetch
    while (yield results.has_next_async()):
  File "google/cloud/ndb/tasklets.py", line 309, in _advance_tasklet
    self.generator.throw(type(error), error, traceback)
  File "google/cloud/ndb/_datastore_query.py", line 264, in has_next_async
    yield self._next_batch()  # First time
  File "google/cloud/ndb/tasklets.py", line 309, in _advance_tasklet
    self.generator.throw(type(error), error, traceback)
  File "google/cloud/ndb/_datastore_query.py", line 291, in _next_batch
    response = yield _datastore_run_query(query)
  File "google/cloud/ndb/tasklets.py", line 309, in _advance_tasklet
    self.generator.throw(type(error), error, traceback)
  File "google/cloud/ndb/_datastore_query.py", line 847, in _datastore_run_query
    "RunQuery", request, timeout=query.timeout
  File "google/cloud/ndb/tasklets.py", line 309, in _advance_tasklet
    self.generator.throw(type(error), error, traceback)
  File "google/cloud/ndb/_retry.py", line 78, in retry_wrapper
    raise error
  File "google/cloud/ndb/_retry.py", line 73, in retry_wrapper
    result = yield result
  File "google/cloud/ndb/tasklets.py", line 309, in _advance_tasklet
    self.generator.throw(type(error), error, traceback)
  File "google/cloud/ndb/_datastore_api.py", line 113, in rpc_call
    result = yield rpc
grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
	status = StatusCode.INVALID_ARGUMENT
	details = "global queries do not support strong consistency"
	debug_error_string = "{"created":"@1582054944.079620000","description":"Error received from peer ipv4:216.58.192.42:443","file":"src/core/lib/surface/call.cc","file_line":1056,"grpc_message":"global queries do not support strong consistency","grpc_status":3}
Thanks!
Metadata
Metadata
Assignees
Labels
🚨This issue needs some love.This issue needs some love.triage meI really want to be triaged.I really want to be triaged.