postgresql 主從 ERROR: canceling statement due to conflict with recovery User query might have needed to see row versions that must be removed.
阿新 • • 發佈:2021-12-14
1.ERROR: canceling statement due to conflict with recovery User query might have needed to see row versions that must be removed.
2. 參考方案:
備庫上需要開啟的引數: max_standby_streaming_delay = 10s hot_standby_feedback = on # 主要是這個引數設定為on即可
參考:PG從庫查詢被終止的解決辦法 (icode9.com)https://www.icode9.com/content-4-514325.html
3. 最佳實踐
1.改大 比如:max_standby_streaming_delay = 30min; 後果是wal空間變大,需監控磁碟空間; 2.不建議 改hot_standby_feedback=on; 這個讀庫有問題會蔓延至寫庫; 3. 最好是能把對應的sql語句調優至比較短時間內執行完畢;
4. 原因分析
這個是在讀庫上查詢資料較久,而對應的資料在寫庫已出現變化,從而出現讀寫資料衝突了
(檢視一般是聯合多個基表查詢,如未加篩選條件會更慢)
用一個例子來演示會更加清晰