1

が、私はこのエラーを得なかっ:TransactionFailedError何のトランザクション

TransactionFailedError: too much contention on these datastore entities. please try again. 

私はどんな取引をしていないよにもかかわらず。エラーの原因と私のコードの行は、それは大したことではないので、このエラーが頻繁に発生しませんが、私はこのエラーを取得する理由は、私が興味

ndb.put_multi(entity_list) # entity_list is a list of 100 entities 

です。何か案は? self.check_rpc_success(rpc):エラーは、実際にRPC応答では、データストア自体から受信されることを

Traceback (most recent call last): 
    ... 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 318, in post 
    self.run_from_request() 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 313, in run_from_request 
    run(self.request.body) 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 155, in run 
    return func(*args, **kwds) 
    File "/base/data/home/apps/s~opavote/2017-09-15.404125237783169549/tasks.py", line 70, in start_election 
    models.Voter.create(e.eid, chunk) 
    File "/base/data/home/apps/s~opavote/2017-09-15.404125237783169549/models.py", line 2426, in create 
    ndb.put_multi(voters + vbs) 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/ext/ndb/model.py", line 3958, in put_multi 
    for future in put_multi_async(entities, **ctx_options)] 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 383, in get_result 
    self.check_success() 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 427, in _help_tasklet_along 
    value = gen.throw(exc.__class__, exc, tb) 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/ext/ndb/context.py", line 824, in put 
    key = yield self._put_batcher.add(entity, options) 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 427, in _help_tasklet_along 
    value = gen.throw(exc.__class__, exc, tb) 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/ext/ndb/context.py", line 358, in _put_tasklet 
    keys = yield self._conn.async_put(options, datastore_entities) 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 513, in _on_rpc_completion 
    result = rpc.get_result() 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 928, in get_result 
    result = rpc.get_result() 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 613, in get_result 
    return self.__get_result_hook(self) 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1893, in __put_hook 
    self.check_rpc_success(rpc) 
    File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1385, in check_rpc_success 
    raise _ToDatastoreError(err) 
TransactionFailedError: too much contention on these datastore entities. please try again. 

答えて

3

注:ここでは

は、トレースバックのほとんどです。

私は、データストア側では、それをサポートする冗長部分の動作の一貫性/信頼性を保証するために、すべての書き込み操作は実際にトランザクション操作と同じ/同様のメカニズムを使用していると考えられます。違いは、クライアント側でRPC交換の前/後にいくつかのトランザクションチェックがあり、データストアのRPC開始/終了トリガーが明示的であることです。 Life of a Datastore Writeから

、いくつかの共通のメカニズムがトランザクションかどうか(強調鉱山)であることに関係なく、操作の使用されていることを示唆している引用:

If the commit phase has succeeded but the apply phase failed, the datastore will roll forward to apply the changes to indexes under two circumstances:

  1. The next time you execute a read or write or start a transaction on this entity group, the datastore will first roll forward and fully apply this committed but unapplied write, based on the data in the log.

と失敗の考えられる理由の一つは、あまりにも多くのだろうたとえ読み込み専用であっても、同じエンティティへの並列アクセスが可能です。その場合はクライアント側のトランザクション用ですが、Contention problems in Google App Engineを参照してください。

これは単なる理論であることに注意してください。)

+0

最初にリンクしたページには、「Bigtableタブレットが利用できないため、書き込みに失敗すると予想されます」と記載されています。私はそれがここで起こったことであり、その失敗はそれを行う際の一部の取引であったと思われる。 –

2

それは様々な定義と制限に注意して、再検討しtransactions and entity groups価値があるかもしれません。

「エンティティの作成、更新、または削除のすべての試みはトランザクションのコンテキストで行われます」、および「1つのエンティティグループ内で1秒あたり約1トランザクションの書き込みスループットの制限があります。 entity_listに同じエンティティグループに属するエンティティが含まれている場合は、特に表示されている内容を話します。

+0

ここに入れるエンティティはすべて作成されており、エンティティグループは使用していません。エンティティを作成するためにトランザクションがフードの下で使用されているようです。エンティティを作成する際に競合する可能性があることは私にとっては奇妙なことです。 –

+2

独自のキー名を指定していますか、またはIDに自動割り当てされていますか?前者は、キーが本当に接近している(例えば、順次)場合に競合の問題を引き起こす可能性がある。自動割り当てされたIDはそれを避けます。 –

+0

別のエンティティのIDと[email protected]のようなユーザーの電子メールアドレスを連結して作成したカスタムキー名があります。いくつかの例では、電子メールアドレスはすべて同じドメインのものであるため、キーの唯一の違いは「_」と「@」の間になります。潜在的に競合の問題を引き起こすために、キーを十分に接近させるのでしょうか? –

関連する問題