英文:
Cannot create foreign key whose evaluation cannot be enforced to remote nodes
问题
"AntDB提示:
> "无法创建无法在远程节点上执行评估的外键"
如何解决这个问题?"
英文:
AntDB prompts:
> "cannot create foreign key whose evaluation cannot be enforced to Remote nodes”
How to solve this?
答案1
得分: 1
目前,不允许在非切片键上创建外键。解决方法如下:
将子表的外键字段修改为切片键,然后创建外键。
如果父表的数据量较小,您可以将父表修改为重复表。
SQL示例:
antdb=# create table t_parent (id int primary key,name varchar(30));
create table t_child (id int,name varchar(30)) distribute by hash(name);
CREATE TABLE
antdb=# create table t_child (id int,name varchar(30)) distribute by hash(name);
CREATE TABLE
antdb=#
antdb=# alter table t_child
postgres-# add constraint fkey_t_child
postgres-# foreign key (id)
postgres-# references t_parent (id);
ERROR: Cannot create foreign key whose evaluation cannot be enforced to remote nodes
antdb=#
antdb=# alter table t_child distribute by hash (id);
ALTER TABLE
antdb=# alter table t_child
add constraint fkey_t_child
foreign key (id)
references t_parent (id);
ALTER TABLE
antdb=# drop table t_child;
DROP TABLE
antdb=# create table t_child (id int,name varchar(30)) distribute by hash(name);
CREATE TABLE
antdb=# alter table t_parent distribute by replication;
ALTER TABLE
antdb=# alter table t_child
postgres-# add constraint fkey_t_child
postgres-# foreign key (id)
postgres-# references t_parent (id);
ALTER TABLE
antdb=#
可能的错误消息:
警告:在协调器上执行 "set FORCE_PARALLEL_MODE = off; SELECT adb_PAUSE_CLUSTER();" 失败 ERROR: poolmgr 返回错误消息:重新连接三次,fe_sendauth: 未提供密码
解决方法:
检查集群中协调器的hba信息以及是否存在:集群中的主机IP的身份验证方法为md5。
执行:在adbmgr中查看节点的hba信息。
致命错误:参数“TimeZone”的值无效:“Asia/Shanghai”
可能的错误消息:
致命错误:参数“TimeZone”的值无效:“Asia/Shanghai”
致命错误:参数“TimeZone”的值无效:“asia/shanghai”
致命错误:参数“TimeZone”的值无效:“utc”
解决方法:
检查JDBC的JAVA_OPTS是否配置了user.timezone参数,如果配置了,需要严格匹配数据库默认支持的时区名称的大小写。
数据库支持的时区使用以下SQL查询。注意时区名称的大小写。
select * from adb_catalog.adb_timezone_names;
如果JDBC中未配置参数,请按照步骤2中的描述进行检查。
检查AntDB二进制目录中的共享目录,并确保timezone目录下的时区是完整的。如果缺少或不完整,需要再次从完整节点部署所需的文件。
ll $ADBHOME/share/postgresql/timezone
total 232
drwxr-xr-x 2 antdb antdb 4096 Apr 16 15:59 Africa
drwxr-xr-x 6 antdb antdb 4096 Apr 16 15:59 America
drwxr-xr-x 2 antdb antdb 4096 Apr 16 15:59 Antarctica
drwxr-xr-x 2 antdb antdb 25 Apr 16 15:59 Arctic
drwxr-xr-x 2 antdb antdb 4096 Apr 16 15:59 Asia
...
drwxr-xr-x 2 antdb antdb 4096 Apr 16 15:59 US
-rwxr-xr-x 1 antdb antdb 114 Apr 16 15:48 UTC
-rwxr-xr-x 1 antdb antdb 1905 Apr 16 15:48 WET
-rwxr-xr-x 1 antdb antdb 1535 Apr 16 15:48 W-SU
-rwxr-xr-x 1 antdb antdb 114 Apr 16 15:48 Zulu
英文:
Currently, foreign keys are not allowed to be created on non-sliced keys. The solution is below:
Modify the foreign key field of the child table to be a sliced key and then create a foreign key.
If the data volume of the parent table is small, you can modify the parent table to be a duplicate table.
Reproduction of SQL:
antdb=# create table t_parent (id int primary key,name varchar(30));
create table t_child (id int,name varchar(30)) distribute by hash(name);
CREATE TABLE
antdb=# create table t_child (id int,name varchar(30)) distribute by hash(name);
CREATE TABLE
antdb=#
antdb=# alter table t_child
postgres-# add constraint fkey_t_child
postgres-# foreign key (id)
postgres-# references t_parent (id);
ERROR: Cannot create foreign key whose evaluation cannot be enforced to remote nodes
antdb=#
antdb=# alter table t_child distribute by hash (id);
ALTER TABLE
antdb=# alter table t_child
add constraint fkey_t_child
foreign key (id)
references t_parent (id);
ALTER TABLE
antdb=# drop table t_child;
DROP TABLE
antdb=# create table t_child (id int,name varchar(30)) distribute by hash(name);
CREATE TABLE
antdb=# alter table t_parent distribute by replication;
ALTER TABLE
antdb=# alter table t_child
postgres-# add constraint fkey_t_child
postgres-# foreign key (id)
postgres-# references t_parent (id);
ALTER TABLE
antdb=#
fe_sendauth: no password supplied
Possible error message:
WARNING: on coordinator execute "set FORCE_PARALLEL_MODE = off; SELECT adb_PAUSE_CLUSTER();" fail ERROR: error message from poolmgr:reconnect three thimes , fe_sendauth: no password supplied
Solution:
Check the hba information of the coords in the cluster and whether it exists or not: the authentication method for host IP with md5 in the cluster.
Execute :show hba nodename in adbmgr to see the hba information of the node.
FATAL: invalid value for parameter “TimeZone”: “Asia/Shanghai”
Possible error message:
FATAL: invalid value for parameter "TimeZone": "Asia/Shanghai"
FATAL: invalid value for parameter "TimeZone": "asia/shanghai"
FATAL: invalid value for parameter "TimeZone": "utc"
Solution:
Check the JAVA_OPTS of JDBC that whether the user.timezone parameter is configured, if the parameter is configured, you need to strictly match the case of the time zone names supported by default within the database.
Time zones supported in the database use the following sql query. Pay attention to the case of the time zone name.
select * from adb_catalog.adb_timezone_names;
If the parameter is not configured in JDBC, check it as described in step 2.
Check the share in the AntDB binaries directory, and make sure the timezone under timezone is complete. If it is missing or incomplete, you need to deploy the required files from a complete node again.
ll $ADBHOME/share/postgresql/timezone
total 232
drwxr-xr-x 2 antdb antdb 4096 Apr 16 15:59 Africa
drwxr-xr-x 6 antdb antdb 4096 Apr 16 15:59 America
drwxr-xr-x 2 antdb antdb 4096 Apr 16 15:59 Antarctica
drwxr-xr-x 2 antdb antdb 25 Apr 16 15:59 Arctic
drwxr-xr-x 2 antdb antdb 4096 Apr 16 15:59 Asia
......
drwxr-xr-x 2 antdb antdb 4096 Apr 16 15:59 US
-rwxr-xr-x 1 antdb antdb 114 Apr 16 15:48 UTC
-rwxr-xr-x 1 antdb antdb 1905 Apr 16 15:48 WET
-rwxr-xr-x 1 antdb antdb 1535 Apr 16 15:48 W-SU
-rwxr-xr-x 1 antdb antdb 114 Apr 16 15:48 Zulu
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论