From d1028fd621438d92d5748db4e853b2fa5aac6684 Mon Sep 17 00:00:00 2001 From: chenxiaobin <1025221611@qq.com> Date: Sun, 25 Apr 2021 10:15:03 +0800 Subject: [PATCH] fixbug: divided by zero --- src/gausskernel/storage/replication/walsender.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gausskernel/storage/replication/walsender.cpp b/src/gausskernel/storage/replication/walsender.cpp index 13bc3992f..181a938da 100644 --- a/src/gausskernel/storage/replication/walsender.cpp +++ b/src/gausskernel/storage/replication/walsender.cpp @@ -5493,7 +5493,8 @@ static void CalCatchupRate() { SpinLockRelease(&walsnd->mutex); return; } - if (TimestampDifferenceExceeds(walsnd->lastCalTime, now, CALCULATE_CATCHUP_RATE_TIME)) { + if (TimestampDifferenceExceeds(walsnd->lastCalTime, now, CALCULATE_CATCHUP_RATE_TIME) && + XLByteLT(walsnd->lastCalWrite, write)) { double tempRate = (double)(now - walsnd->lastCalTime) / (double)XLByteDifference(write, walsnd->lastCalWrite); walsnd->catchupRate = walsnd->catchupRate == 0 ? tempRate : (walsnd->catchupRate + tempRate) / 2;