diff --git a/src/database/engine/pdc.c b/src/database/engine/pdc.c
index 28a83e2bc1..da5dbd7d84 100644
--- a/src/database/engine/pdc.c
+++ b/src/database/engine/pdc.c
@@ -184,12 +184,12 @@ static struct {
                 .allocated = 0,
                 .allocated_bytes = 0,
         },
-        .max_size = MAX_PAGES_PER_EXTENT * RRDENG_BLOCK_SIZE,
+        .max_size = MAX_EXTENT_UNCOMPRESSED_SIZE
 };
 
 void extent_buffer_init(void) {
-    size_t max_extent_uncompressed = MAX_PAGES_PER_EXTENT * RRDENG_BLOCK_SIZE;
-    size_t max_size = (size_t)LZ4_compressBound(MAX_PAGES_PER_EXTENT * RRDENG_BLOCK_SIZE);
+    size_t max_extent_uncompressed = MAX_EXTENT_UNCOMPRESSED_SIZE;
+    size_t max_size = (size_t)LZ4_compressBound(MAX_EXTENT_UNCOMPRESSED_SIZE);
     if(max_size < max_extent_uncompressed)
         max_size = max_extent_uncompressed;
 
@@ -1010,7 +1010,7 @@ static bool epdl_populate_pages_from_extent_data(
             uncompressed_payload_length += header->descr[i].page_length;
         }
 
-        if(unlikely(uncompressed_payload_length > MAX_PAGES_PER_EXTENT * RRDENG_BLOCK_SIZE))
+        if(unlikely(uncompressed_payload_length > MAX_EXTENT_UNCOMPRESSED_SIZE))
             have_read_error = true;
 
         if(likely(!have_read_error)) {
diff --git a/src/database/engine/rrdengine.h b/src/database/engine/rrdengine.h
index 691f0ea7a8..0a22477acf 100644
--- a/src/database/engine/rrdengine.h
+++ b/src/database/engine/rrdengine.h
@@ -30,6 +30,9 @@ struct rrdeng_cmd;
 #define MAX_PAGES_PER_EXTENT (109) /* TODO: can go higher only when journal supports bigger than 4KiB transactions */
 #define DEFAULT_PAGES_PER_EXTENT (109)
 
+#define MAX_EXTENT_UNCOMPRESSED_SIZE (MAX_PAGES_PER_EXTENT * (RRDENG_BLOCK_SIZE + RRDENG_GORILLA_32BIT_BUFFER_SIZE))
+
+
 #define RRDENG_FILE_NUMBER_SCAN_TMPL "%1u-%10u"
 #define RRDENG_FILE_NUMBER_PRINT_TMPL "%1.1u-%10.10u"