相关疑难解决方法(0)

在 Postgres 上使用两阶段提交

假设“db1”中有一个名为“t1”的表,“db2”中有一个名为“t2”的表,我需要在两个表上插入一条记录,否则会失败。

连接到 db1,我想我应该输入以下内容:

BEGIN;
PREPARE TRANSACTION 'pepe'; -- this says the manual that makes your transaction gets stored on disk, so what is the purpose if I can't use it from another database?)

insert into t1 (field) values ('a_value');

COMMIT PREPARED 'pepe'
Run Code Online (Sandbox Code Playgroud)

连接到db2,我猜:

BEGIN;
PREPARE TRANSACTION 'pepe'; -- this fails (the name of the transaction, what is the meaning, what is use for?)
 -- It complains about this "ERROR:  transaction identifier "pepe" is already in use"

insert into t2 (field) …
Run Code Online (Sandbox Code Playgroud)

postgresql two-phase-commit

7
推荐指数
1
解决办法
8348
查看次数

标签 统计

postgresql ×1

two-phase-commit ×1