4

I have created following function in pgpool .

CREATE OR REPLACE Function fun1(Id int)
RETURNS boolean as $executionStatus$
DECLARE

BEGIN
    DELETE FROM table1 where table1_id =  Id ; 
    DELETE from table2 where table2_id =  Id ;
    DELETE from table3 where table3_id =  Id ;
    RETURN true;
END;
$executionStatus$ LANGUAGE plpgsql;

I run following command inside the postgres shell of pgpool

select fun1(1);

It is deleted the data only from master. I tried again then it is deleted from different server.So replication fails in this case. But if i use delete queries separately then it is working fine.It is deleting data from all servers.

DELETE FROM table1 where table1_id =  1 ;DELETE from table2 where table2_id =  1 ;DELETE from table3 where table3_id =  1 ;

Please let me know how to fix this issue .

4

1 回答 1

3

我自己找到了答案 在复制模式(replication_mode = on)中,SELECT 是负载平衡的,只有一个 PostgreSQL 服务器接收命令。解决方案是:

1) 在 SELECT 前面添加“/*REPLICATION*/”注释。

2) 将 func1 添加到 black_function_list。

于 2016-05-24T08:31:13.917 回答