pg_upgrade升級報錯:Only the install user can be defined in the new cluster

 

  前兩天pg11剛出來,打算測試一下,想將測試庫升級到pg11,以前測試庫的版本是pg9.6,後面我將它升到了pg10,打算在pg10的版本基礎上升級到pg11。post

  但執行時,屢次報出:測試

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中找到該報錯的緣由ui

    /*
     * 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時,可能會報錯。spa

 

後面又查了一下環境變量,發現環境變量中配置了一個測試庫的用戶,而不是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。反覆操做了三四次都是一樣的結果。操作系統

 若有知道緣由的請告知一下,謝謝。rest

 

另外,在安裝pg11時,注意參數--wal-segsize放在了initdb部分,須要在作初始化時設置,在編譯部分已經沒有這個參數了。code

相關文章
相關標籤/搜索