Postgresql

pg_restore 以“記憶體不足”錯誤終止

  • July 13, 2021

試圖恢復一個 45mb 的 pg_dump 文件,但它一直失敗並出現“記憶體不足”錯誤。

我的 postgresql-10-main.log 的內容:

2018-01-16 06:14:50.692 WAT [32405] postgres@app_development LOG:  

could not receive data from client: Connection reset by peer
2018-01-16 06:14:50.692 WAT [32405] postgres@app_development CONTEXT:  COPY assessment_scores, line 15347
2018-01-16 06:14:50.692 WAT [32405] postgres@app_development STATEMENT:  COPY assessment_scores (id, student_id, assessment_id, score, exempt, late, collected, missing, comment, deleted_at, created_at, updated_at) FROM stdin;

2018-01-16 06:14:50.693 WAT [32405] postgres@app_development LOG:  incomplete message from client
2018-01-16 06:14:50.693 WAT [32405] postgres@app_development CONTEXT:  COPY assessment_scores, line 15347
2018-01-16 06:14:50.693 WAT [32405] postgres@app_development STATEMENT:  COPY assessment_scores (id, student_id, assessment_id, score, exempt, late, collected, missing, comment, deleted_at, created_at, updated_at) FROM stdin;

2018-01-16 06:14:50.693 WAT [32405] postgres@app_development ERROR:  unexpected EOF on client connection with an open transaction
2018-01-16 06:14:50.693 WAT [32405] postgres@app_development CONTEXT:  COPY assessment_scores, line 15347
2018-01-16 06:14:50.693 WAT [32405] postgres@app_development STATEMENT:  COPY assessment_scores (id, student_id, assessment_id, score, exempt, late, collected, missing, comment, deleted_at, created_at, updated_at) FROM stdin;

2018-01-16 06:14:50.693 WAT [32405] postgres@app_development FATAL:  terminating connection because protocol synchronization was lost
2018-01-16 06:14:50.693 WAT [32405] postgres@app_development LOG:  could not send data to client: Broken pipe

我用 HTOP 檢查過,我的 RAM 大約是 4GB/8GB,發生這種情況時 SWAP 空間未使用。

數據庫伺服器是本地主機。

想通了問題。

我試圖將數據庫轉儲從 Postgres 9.6 導入 Postgres 10。

降級到 Postgres 9.6 並成功導入。

由於伺服器端日誌中沒有提到“記憶體不足”,而且顯然您的客戶端(pg_restore在這種情況下)死了,我敢打賭 OOM 發生在您的本地電腦上。解決這個問題可能取決於許多因素 - 嘗試關閉消耗大量 RAM 的程序、添加更多交換或其他。

引用自:https://dba.stackexchange.com/questions/195456