pg_upgrade升级报错:Only the install user can be defined in the new cluster

 

  前两天pg11刚出来,打算测试一下,想将测试库升级到pg11,之前测试库的版本是pg9.6,后面我将它升到了pg10,打算在pg10的版本基础上升级到pg11。

  但执行时,多次报出:

Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch       ok
Checking for presence of required libraries                 ok
Checking database user is the install user                  Only the install user can be defined in the new cluster.

所以就搜了一下代码,在src/bin/pg_upgrade/check.c中找到该报错的原因

    /*
     * We only allow the install user in the new cluster because other defined
     * users might match users defined in the old cluster and generate an
     * error during pg_dump restore.
     */
    if (cluster == &new_cluster && atooid(PQgetvalue(res, 0, 0)) != 1)
        pg_fatal("Only the install user can be defined in the new cluster.\n");

pg_upgrade升级时,只允许使用安装新集群时所用的用户,这是因为在旧集群中存在的用户在执行pg_dump和restore时,可能会报错。

 

后面又查了一下环境变量,发现环境变量中配置了一个测试库的用户,而不是postgres用户。怀疑无论是在做initdb还是pg_upgrade时,都不应该走环境变量的用户,而且在执行pg_upgrade时,已经明确指定了使用postgres,那么可能出在initdb上,但重新测试发现无论initdb时,指没指定是否是postgres用户,都是按照postgres来初始化的,它是跟着操作系统用户走的。后来又重试了几遍,发现执行检测没问题,但到了实际执行时,总会报Only the install user can be defined in the new cluster的错误,然后删掉生成pg11版本的表空间数据,删掉初始化的新集群,再重新初始化,然后执行pg_ugrade的检测和实际执行就又变正常了,至此感觉碰到了bug。反复操作了三四次都是同样的结果。

 如有知道原因的请告知一下,谢谢。

 

另外,在安装pg11时,注意参数--wal-segsize放在了initdb部分,需要在做初始化时设置,在编译部分已经没有这个参数了。

 

 

posted on 2018-10-23 16:59  Still water run deep  阅读(606)  评论(0编辑  收藏  举报

导航