最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

postgresql - Sharding error when inserting data into ShardingSphere-Proxy with AlloyDB - Stack Overflow

programmeradmin5浏览0评论

Sharding error when inserting data into ShardingSphere-Proxy with AlloyDB

I am using ShardingSphere-Proxy with AlloyDB and I am facing an error when trying to insert data into the ni_contribuinte table.

Error when executing an INSERT:

rtc_db_des_aa=> INSERT INTO identifier(identifier) VALUES ('1a2b3c4d5e');
ERROR: Inline sharding algorithms expression 'shard_${(abs(identifier.hashCode())) % 5}' and sharding column 'identifier' do not match.

My table schema is as follows:

Table "identifier" {
"identifier" "character varying(14)" [pk, not null]
}

And my ShardingSphere configuration is as follows:

databaseName: rtc_db_des_aa
dataSources:
shard_0:
url: jdbc:postgresql://10.0.0.2:5432/rtc_db_des_aa
username: postgres
password: "pass"
shard_1:
url: jdbc:postgresql://10.0.0.7:5432/rtc_db_des_aa
username: postgres
password: "pass"
shard_2:
url: jdbc:postgresql://10.0.0.8:5432/rtc_db_des_aa
 username: postgres
 password: "pass"
 shard_3:
 url: jdbc:postgresql://10.0.0.9:5432/rtc_db_des_aa
 username: postgres
 password: "pass"
 shard_4:
 url: jdbc:postgresql://10.0.0.10:5432/rtc_db_des_aa
 username: postgres
 password: "pass"

rules:
 - !SHARDING
 tables:
 identifier:
 actualDataNodes: shard_${0..4}.identifier
 tableStrategy:
 standard:
 shardingColumn: identifier
 shardingAlgorithmName: hash_inline

 shardingAlgorithms:
hash_inline:
type: INLINE
props:
sharding-count: 5
algorithm-expression: shard_${(abs(identifier.hashCode())) % 5}

From the error, it seems that the sharding expression is not being applied correctly to the ni_contribuinte column. What could be causing this?

I have already tried:

  • Making sure that the identifier column is correctly set to character varying(14).
  • Testing other sharding expressions, but I still get the same error.

Could someone help me understand what the problem might be?

  1. List item
发布评论

评论列表(0)

  1. 暂无评论