当 运行 6 台点燃服务器时获取不完整的数据

Getting incomplete data when running 6 ignite servers

我是 运行 6 Ignite 服务器,版本为 2.7.5。问题是当我使用我的客户端 API 进行查询时,我没有获得所有记录。只有一些记录即将到来。我正在使用分区缓存。我不想使用复制模式。当使用 DBeaver 查询时,它显示所有记录都已被提取。

以下代码用于获取数据:

public List<Long> getGroupIdsByUserId(Long createdBy) {
    final String query = "select g.groupId from groups g where g.createdBy = ? and g.isActive = 1";
    SqlFieldsQuery sql = new SqlFieldsQuery(query);
    sql.setArgs(createdBy);
    List<List<?>> rsList = groupsCache.query(sql).getAll();
    List<Long> ids = new ArrayList<>();
    for (List<?> l : rsList) {
        ids.add((Long)l.get(0));
    }
    return ids;
}

点燃版本 - 2.7.5

客户端查询方式

连接查询是:

    final String query = "select distinct u.userId from 
    groupusers gu "
                + "inner join \"GroupsCache\".groups g on gu.groupId = g.groupId 
"
                + "inner join \"OrganizationsCache\".organizations o on 
gu.organizationId = o.organizationId "
                + "inner join \"UsersCache\".users u on gu.userId = u.userId 
where "     + "g.groupId = ? and "
                + "g.isActive = 1 and " + "gu.isActive = 1 and " + 
"gu.createdBy 
    = ? and " + "o.organizationId = ? and "
                + "o.isActive = 1 and " + "u.isActive = 1";

对于连接查询,数据库中的实际记录为 120,但对于 ignite 客户端,只有 3-4 条记录正在提交。并且它们不一致。有时是 3 条记录,有时是 4 条记录。并查询

select g.groupId from groups g where g.createdBy = ? and g.isActive = 1 

实际记录是27条,但即将记录有时是20条有时是19条有时是完整的。请帮助我解决这个问题以及并置连接..

这很可能意味着您的亲和力不正确。

Apache Ignite 假定您的数据具有适当的亲和力,即当连接两个表时,要连接的行将始终在同一节点上可用。当您通过主键或通过标记为关联列的主键的一部分(例如通过 @AffinityKeyMapped 注释)加入时,这将起作用。有一个 documentation page about affinity.

您可以通过将 distribtedJoins 连接设置设置为 true 来检查。如果你看到之后的所有记录,说明你需要修复亲和力