apache / apache/incubator-seata

springboot + shardingSphere5.0 + Dubbo2.7.x实现分库分表的情况下,集成 + seata1.4.2后,报出以下异常: Could not found any index in the table: xxx

Open
#4,252 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
26k
Forks
8.8k
Avg merge
1d 8h
Merged PRs (30d)
4

Description

各位大神好,我在springboot + shardingSphere5.0 + Dubbo2.7.x实现分库分表(3个库,t_order分4张表)的情况下,集成 + seata1.4.2后,报出以下异常:
Could not found any index in the table: xxx,查看了下源码,在io.seata.rm.datasource.sql.struct.cache.MysqlTableMetaCache#resultSetMetaToSchema方法中,会判断所有index是否为空,

```
try (ResultSet rsColumns = dbmd.getColumns(catalogName, schemaName, tableName, "%");
ResultSet rsIndex = dbmd.getIndexInfo(catalogName, schemaName, tableName, false, true)) {
while (rsIndex.next()) {
String indexName = rsIndex.getString("INDEX_NAME");
String colName = rsIndex.getString("COLUMN_NAME");
ColumnMeta col = tm.getAllColumns().get(colName);

if (tm.getAllIndexes().containsKey(indexName)) {
IndexMeta index = tm.getAllIndexes().get(indexName);
index.getValues().add(col);
} else {
IndexMeta index = new IndexMeta();
index.setIndexName(indexName);
index.setNonUnique(rsIndex.getBoolean("NON_UNIQUE"));
index.setIndexQualifier(rsIndex.getString("INDEX_QUALIFIER"));
index.setIndexName(rsIndex.getString("INDEX_NAME"));
index.setType(rsIndex.getShort("TYPE"));
index.setOrdinalPosition(rsIndex.getShort("ORDINAL_POSITION"));
index.setAscOrDesc(rsIndex.getString("ASC_OR_DESC"));
index.setCardinality(rsIndex.getInt("CARDINALITY"));
index.getValues().add(col);
if ("PRIMARY".equalsIgnoreCase(indexName)) {
index.setIndextype(IndexType.PRIMARY);
} else if (!index.isNonUnique()) {
index.setIndextype(IndexType.UNIQUE);
} else {
index.setIndextype(IndexType.NORMAL);
}
tm.getAllIndexes().put(indexName, index);

}
}
if (tm.getAllIndexes().isEmpty()) {
throw new ShouldNeverHappenException("Could not found any index in the table: " + tableName);
}
}
return tm;
```

【(tm.getAllIndexes().isEmpty()】这行条件成立就会抛出异常,请问此处的判断是什么用意,谢谢。
PS:表中都有主键

Contributor guide

Open the contributing guide

Research direction

Start by reading io.seata.rm.datasource.sql.struct.cache.MysqlTableMetaCache#resultSetMetaToSchema and the shown getIndexInfo handling. Reproduce the Spring Boot, ShardingSphere, Dubbo, and Seata setup against the described three databases and four t_order tables, then inspect the metadata returned for the primary keys. Done means explaining why no indexes are found and documenting or resolving the resulting exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mysql, spring-boot
Domain
databases, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.