【问题标题】:Missing entities after insertion in Google Cloud DataStore插入 Google Cloud DataStore 后缺少实体
【发布时间】:2017-07-09 10:25:40
【问题描述】:

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

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

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();

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

提前致谢

【问题讨论】:

    标签: google-cloud-datastore app-engine-flexible


    【解决方案1】:

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

    这篇文章应该解释更多:

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

    【讨论】:

    【解决方案2】:

    经过更多研究,我认为这可能与索引有关。我相信在我运行查询时索引的更新速度还不够快。实体有很多属性,所以涉及到很多索引。

    【讨论】:

      猜你喜欢
      • 2020-05-05
      • 1970-01-01
      • 2018-07-27
      • 1970-01-01
      • 1970-01-01
      • 2018-08-24
      • 2021-04-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多