我在2.7.5版本上运行6个Ignite服务器。问题是,当我使用客户端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;
}Ignite版本- 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";对于join查询,数据库中的实际记录是120,但对于ignite客户端,只有3-4条记录在.and中,它们不一致。有时是3条记录,有时是4条记录。和for查询
select g.groupId from groups g where g.createdBy = ? and g.isActive = 1 实际记录是27条,但正在使用的记录有时是20条,有时是19条,有时是完整的。请帮我解决这个和并置连接问题..
发布于 2019-09-23 17:02:21
这很可能意味着您的亲和力不正确。
Apache Ignite假设您的数据具有适当的亲和性,即当连接两个表时,要连接的行将始终在同一节点上可用。当您通过主键或标记为亲和列的主键的一部分(例如,通过@AffinityKeyMapped注释)进行连接时,这是有效的。有一个documentation page about affinity。
您可以通过将distribtedJoins连接设置设置为true来进行检查。如果您看到之后的所有记录,这意味着您需要修复您的亲和性。
https://stackoverflow.com/questions/57887737
复制相似问题