插入Google Cloud DataStore后缺少实体 [英] Missing entities after insertion in Google Cloud DataStore

查看:67
本文介绍了插入Google Cloud DataStore后缺少实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google Cloud DataStore中插入一种单一类型的29447个实体后,我等待大约30秒钟,然后检查该特定类型有多少个实体.令人惊讶的是,我注意到其中有些缺失( getCurrentKeys 返回的少于29447个实体).在较长时间(约1个小时)后进行检查时,我可以看到所有实体都在那里( getCurrentKeys 返回了预期的29447个实体).

After inserting 29447 entities of a single kind in Google Cloud DataStore I wait about 30 seconds and go and check how many entities are there for that particular kind. The surprising thing is that I notice some of them missing (getCurrentKeys returns a bit less than 29447 entities). When I check after a longer period of time (~1 hour), I can then see that all of the entities are there (getCurrentKeys returns the expected 29447 entities).

用于读取实体数量的代码如下:

The code used to read the number of entities is the following:

const runQuery = (query) => {
  return new Promise((resolve, reject) => {
    datastore.runQuery(query)
      .then(results => {
        const entities = results[0];
        resolve(entities);
      })
      .catch(e => reject(e));
  });
};

const getCurrentKeys = () => {
  const query = datastore.createQuery(KIND)
    .select('__key__');
  return runQuery(query);
};

async function main() {
  const currentKeys = await getCurrentKeys();
  console.log(`currentKeys: ${currentKeys.length}`);
}

main();

有什么可能发生的想法吗?

Any ideas of what could be happening?

预先感谢

推荐答案

非祖先查询最终是一致的.所有行都需要一段时间才能显示出来.

Non ancestor queries are eventually consistent. It will take a while before all the rows will show up.

本文应进一步说明:

https://cloud.google.com/datastore/docs/articles/balancing-strong-and-eventual-consistency-with-google-cloud-datastore/

这篇关于插入Google Cloud DataStore后缺少实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆