agora inbox for pgsql-hackers@postgresql.orghelp / color / mirror / Atom feed
[PATCH v5 10/10] Additional validation for buffer in the ring 107+ messages / 2 participants [nested] [flat]
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v5 10/10] Additional validation for buffer in the ring @ 2025-06-11 12:45 Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Ashutosh Bapat @ 2025-06-11 12:45 UTC (permalink / raw) If the buffer pool has been shrunk, the buffers in the buffer list may not be valid anymore. Modify GetBufferFromRing to check if the buffer is still valid before using it. This makes GetBufferFromRing() a bit more expensive because of additional boolean condition. That may not be expensive enough to affect query performance. The alternative to that is more complex as explained below. The strategy object is created in CurrentMemoryContext and is not available in any global structure thus accessible when processing buffer resizing barriers. We may modify GetAccessStrategy() to register strategy in a global linked list and then arrange to deregister it once it's no more in use. Looking at the places which use GetAccessStrategy(), fixing all those may be some work. Ashutosh Bapat --- src/backend/storage/buffer/freelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 41641bb3ae6..74d070733a4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -948,12 +948,13 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state) strategy->current = 0; /* - * If the slot hasn't been filled yet, tell the caller to allocate a new - * buffer with the normal allocation strategy. He will then fill this - * slot by calling AddBufferToRing with the new buffer. + * If the slot hasn't been filled yet or the buffer in the slot has been + * invalidated when buffer pool was shrunk, tell the caller to allocate a new + * buffer with the normal allocation strategy. He will then fill this slot + * by calling AddBufferToRing with the new buffer. */ bufnum = strategy->buffers[strategy->current]; - if (bufnum == InvalidBuffer) + if (bufnum == InvalidBuffer || bufnum > NBuffers) return NULL; /* -- 2.49.0 --bwrlgp6w2ubxykjq-- ^ permalink raw reply [nested|flat] 107+ messages in thread
* [PATCH v1 5/6] Handle pg_get_expr default args in system_functions.sql @ 2025-12-09 19:17 Mark Wong <markwkm@gmail.com> 0 siblings, 0 replies; 107+ messages in thread From: Mark Wong @ 2025-12-09 19:17 UTC (permalink / raw) Modernize pg_get_expr to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 1f89dcc7908..81d210a9c45 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -692,6 +692,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_constraintdef'; +CREATE OR REPLACE FUNCTION + pg_get_expr(expr pg_node_tree, relation oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_expr'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 416144c49f5..9effa02fa2e 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2573,23 +2573,6 @@ decompile_column_index_array(Datum column_index_array, Oid relId, */ Datum pg_get_expr(PG_FUNCTION_ARGS) -{ - text *expr = PG_GETARG_TEXT_PP(0); - Oid relid = PG_GETARG_OID(1); - text *result; - int prettyFlags; - - prettyFlags = PRETTYFLAG_INDENT; - - result = pg_get_expr_worker(expr, relid, prettyFlags); - if (result) - PG_RETURN_TEXT_P(result); - else - PG_RETURN_NULL(); -} - -Datum -pg_get_expr_ext(PG_FUNCTION_ARGS) { text *expr = PG_GETARG_TEXT_PP(0); Oid relid = PG_GETARG_OID(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index a9431ea4037..10c5286bd7d 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1716', descr => 'deparse an encoded expression', - proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', - proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, { oid => '1665', descr => 'name of sequence for a serial column', proname => 'pg_get_serial_sequence', provolatile => 's', prorettype => 'text', proargtypes => 'text text', prosrc => 'pg_get_serial_sequence' }, @@ -8502,7 +8499,7 @@ { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', - proargtypes => 'pg_node_tree oid bool', prosrc => 'pg_get_expr_ext' }, + proargtypes => 'pg_node_tree oid bool', prosrc => 'pg_get_expr' }, { oid => '2510', descr => 'get the prepared statements for this session', proname => 'pg_prepared_statement', prorows => '1000', proretset => 't', provolatile => 's', proparallel => 'r', prorettype => 'record', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0006-Handle-pg_get_triggerdef-default-args-in-system_f.patch ^ permalink raw reply [nested|flat] 107+ messages in thread
end of thread, other threads:[~2025-12-09 19:17 UTC | newest] Thread overview: 107+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-06-11 12:45 [PATCH v5 10/10] Additional validation for buffer in the ring Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> 2025-12-09 19:17 [PATCH v1 5/6] Handle pg_get_expr default args in system_functions.sql Mark Wong <markwkm@gmail.com>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox