Bil*_*ill 8 postgresql replication postgresql-10
在我的本地机器上,我刚刚升级到最新的 postgres.app 以获得版本 10。在此之前,我在 9.6 数据库上运行 pg_dumpall,然后在安装版本 10 后,我执行脚本以重新创建数据库、用户、等等...我还在从 dumpall 运行脚本并更新了一些日志记录设置后将 wal_level 更改为逻辑级别。
我首先在dot数据库中创建了一个订阅(作为超级用户)
bill=# \connect dot;
You are now connected to database "dot" as user "bill".
dot=# create publication foo for table dot.item;
CREATE PUBLICATION
Run Code Online (Sandbox Code Playgroud)
item 表中大约有 39k 行,所以同步数据应该不会花那么长时间。
接下来,我创建了一个新数据库dot2,该dot数据库由与该数据库相同的用户拥有,并在与dot数据库中存在的架构相同的模式中创建了一个空项目表,然后我尝试订阅另一个数据库中的发布(也作为超级用户)。
bill=# \connect dot2;
You are now connected to database "dot2" as user "bill".
dot2=# create subscription bar connection 'host=localhost port=5432 dbname=dot connect_timeout=10' PUBLICATION foo;
Run Code Online (Sandbox Code Playgroud)
然而,这只是挂起。它不会返回。
在我的日志中,我看到的只是这个......
2017-11-26 21:36:52.828 EST bill@dot2 54567 [local] STATEMENT: create subscription bar connection 'host=localhost port=5432 dbname=dot connect_timeout=10' PUBLICATION foo;
2017-11-26 21:36:55.122 EST bill@dot 54978 ::1(61990) LOG: duration: 9.328 ms statement: SELECT DISTINCT t.schemaname, t.tablename
FROM pg_catalog.pg_publication_tables t
WHERE t.pubname IN ('foo')
2017-11-26 21:36:55.126 EST bill@dot 54978 ::1(61990) LOG: logical decoding found initial starting point at 0/4584A5A8
2017-11-26 21:36:55.126 EST bill@dot 54978 ::1(61990) DETAIL: Waiting for transactions (approximately 1) older than 1613 to end.
Run Code Online (Sandbox Code Playgroud)
试图查看 pg_stat_activity(免责声明——我不知道我在这里做什么),我在发布数据库中看到了这个......
编辑从 pg_state 添加更多详细信息。为(某些)简洁起见省略了空值。
dot=# select * from pg_stat_activity;
-[ RECORD 1 ]----+-------------------------------------------------------------------------------------------------------------
pid | 54323
backend_start | 2017-11-26 21:04:40.467211-05
wait_event_type | Activity
wait_event | AutoVacuumMain
backend_type | autovacuum launcher
-[ RECORD 2 ]----+-------------------------------------------------------------------------------------------------------------
pid | 54325
usesysid | 10
usename | postgres
backend_start | 2017-11-26 21:04:40.467857-05
wait_event_type | Activity
wait_event | LogicalLauncherMain
backend_type | background worker
-[ RECORD 3 ]----+-------------------------------------------------------------------------------------------------------------
datid | 16391
datname | dot
pid | 54978
usesysid | 16384
usename | bill
application_name | bar
client_addr | ::1
client_port | 61990
backend_start | 2017-11-26 21:36:55.110362-05
xact_start |
query_start | 2017-11-26 21:36:55.113552-05
state_change | 2017-11-26 21:36:55.122976-05
wait_event_type | Lock
wait_event | transactionid
state | idle
query | SELECT DISTINCT t.schemaname, t.tablename +
| FROM pg_catalog.pg_publication_tables t +
| WHERE t.pubname IN ('foo')
backend_type | walsender
-[ RECORD 4 ]----+-------------------------------------------------------------------------------------------------------------
datid | 16391
datname | dot
pid | 54533
usesysid | 16384
usename | bill
application_name | psql
client_port | -1
backend_start | 2017-11-26 21:07:00.309111-05
xact_start | 2017-11-26 22:16:11.140318-05
query_start | 2017-11-26 22:16:11.140318-05
state_change | 2017-11-26 22:16:11.140321-05
state | active
backend_xmin | 1612
query | select * from pg_stat_activity;
backend_type | client backend
-[ RECORD 5 ]----+-------------------------------------------------------------------------------------------------------------
datid | 18611
datname | dot2
pid | 54567
usesysid | 16384
usename | bill
application_name | psql
client_port | -1
backend_start | 2017-11-26 21:09:12.969232-05
xact_start | 2017-11-26 21:36:55.106831-05
query_start | 2017-11-26 21:36:55.106831-05
state_change | 2017-11-26 21:36:55.106835-05
wait_event_type | Client
wait_event | LibPQWalReceiverReceive
state | active
backend_xid | 1612
backend_xmin | 1612
query | create subscription bar connection 'host=localhost port=5432 dbname=dot connect_timeout=10' PUBLICATION foo;
backend_type | client backend
-[ RECORD 6 ]----+-------------------------------------------------------------------------------------------------------------
pid | 54321
backend_start | 2017-11-26 21:04:40.466525-05
wait_event_type | Activity
wait_event | BgWriterMain
backend_type | background writer
-[ RECORD 7 ]----+-------------------------------------------------------------------------------------------------------------
pid | 54320
backend_start | 2017-11-26 21:04:40.466302-05
wait_event_type | Activity
wait_event | CheckpointerMain
backend_type | checkpointer
-[ RECORD 8 ]----+-------------------------------------------------------------------------------------------------------------
pid | 54322
backend_start | 2017-11-26 21:04:40.466712-05
wait_event_type | Activity
wait_event | WalWriterMain
backend_type | walwriter
Run Code Online (Sandbox Code Playgroud)
根据要求添加 pg_locks。同样,空值被忽略。
dot=# select * from pg_locks;
-[ RECORD 1 ]------+-----------------
locktype | relation
database | 18611
relation | 6102
virtualtransaction | 5/16
pid | 54567
mode | RowExclusiveLock
granted | t
fastpath | t
-[ RECORD 2 ]------+-----------------
locktype | relation
database | 18611
relation | 18635
virtualtransaction | 5/16
pid | 54567
mode | AccessShareLock
granted | t
fastpath | t
-[ RECORD 3 ]------+-----------------
locktype | virtualxid
virtualxid | 5/16
virtualtransaction | 5/16
pid | 54567
mode | ExclusiveLock
granted | t
fastpath | t
-[ RECORD 4 ]------+-----------------
locktype | relation
database | 16391
relation | 11577
virtualtransaction | 4/21
pid | 54533
mode | AccessShareLock
granted | t
fastpath | t
-[ RECORD 5 ]------+-----------------
locktype | virtualxid
virtualxid | 4/21
virtualtransaction | 4/21
pid | 54533
mode | ExclusiveLock
granted | t
fastpath | t
-[ RECORD 6 ]------+-----------------
locktype | transactionid
transactionid | 1612
virtualtransaction | 5/16
pid | 54567
mode | ExclusiveLock
granted | t
fastpath | f
-[ RECORD 7 ]------+-----------------
locktype | object
database | 0
classid | 6100
objid | 18661
objsubid | 0
virtualtransaction | 5/16
pid | 54567
mode | AccessShareLock
granted | t
fastpath | f
-[ RECORD 8 ]------+-----------------
locktype | transactionid
transactionid | 1612
virtualtransaction | 3/0
pid | 54978
mode | ShareLock
granted | f
fastpath | f
-[ RECORD 9 ]------+-----------------
locktype | relation
database | 0
relation | 6100
virtualtransaction | 5/16
pid | 54567
mode | RowExclusiveLock
granted | t
fastpath | f
-[ RECORD 10 ]-----+-----------------
locktype | object
database | 0
classid | 1260
objid | 16384
objsubid | 0
virtualtransaction | 5/16
pid | 54567
mode | AccessShareLock
granted | t
fastpath | f
Run Code Online (Sandbox Code Playgroud)
我尝试重新启动数据库,并且关闭了可能连接到它的所有进程。我使用的唯一可以连接到它的是我用来连接到 pub 和 sub 数据库的两个 psql 实例。
知道为什么会发生这种情况,或者我应该查看什么来弄清楚它为什么在等待?
| 归档时间: |
|
| 查看次数: |
2980 次 |
| 最近记录: |