From a7251157d42a81f5e92a4594bcd43081888356a1 Mon Sep 17 00:00:00 2001
From: Kuntal Ghosh <kuntal.ghosh@enterprisedb.com>
Date: Mon, 5 Nov 2018 16:31:38 +0530
Subject: [PATCH] Fix shared memory size for rollback hash table

While creating shared memory segment for rollback hash table, we should
set the size of the segment correctly.
---
 src/backend/access/undo/undoaction.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/backend/access/undo/undoaction.c b/src/backend/access/undo/undoaction.c
index bdf9d1e013..3cb0b8216f 100644
--- a/src/backend/access/undo/undoaction.c
+++ b/src/backend/access/undo/undoaction.c
@@ -625,7 +625,7 @@ execute_undo_actions_page(List *luinfo, UndoRecPtr urec_ptr, Oid reloid,
 int
 RollbackHTSize(void)
 {
-	return ROLLBACK_HT_SIZE * sizeof(RollbackHashEntry);
+	return hash_estimate_size(ROLLBACK_HT_SIZE, sizeof(RollbackHashEntry));
 }
 
 /*
@@ -635,7 +635,6 @@ RollbackHTSize(void)
 void
 InitRollbackHashTable(void)
 {
-	int ht_size = RollbackHTSize();
 	HASHCTL info;
 	MemSet(&info, 0, sizeof(info));
 
@@ -644,8 +643,8 @@ InitRollbackHashTable(void)
 	info.hash = tag_hash;
 
 	RollbackHT = ShmemInitHash("Undo actions Lookup Table",
-								ht_size, ht_size, &info,
-								HASH_ELEM | HASH_FUNCTION);
+								ROLLBACK_HT_SIZE, ROLLBACK_HT_SIZE, &info,
+								HASH_ELEM | HASH_FUNCTION | HASH_FIXED_SIZE);
 }
 
 /*
-- 
2.17.1

