Skip to content

pg_buffercache tap test for buffer resize#6

Open
palak-chaturvedi wants to merge 9 commits into
ashutosh-bapat:dev/shbuf_resizefrom
palak-chaturvedi:dev/pg_buffercachetest
Open

pg_buffercache tap test for buffer resize#6
palak-chaturvedi wants to merge 9 commits into
ashutosh-bapat:dev/shbuf_resizefrom
palak-chaturvedi:dev/pg_buffercachetest

Conversation

@palak-chaturvedi

Copy link
Copy Markdown

No description provided.

@palak-chaturvedi palak-chaturvedi marked this pull request as ready for review February 25, 2026 15:23
Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
Comment thread contrib/pg_buffercache/t/001_basic.pl
Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
# Wake up buffercache scan
$node->safe_psql('postgres', "SELECT injection_points_wakeup('$buffercache_injection_point')");

$buffercache_session->query(q(\echo 'done'));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance we can receive the output of the buffer scan query here and then validate the count returned?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you addressed this comment?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread contrib/pg_buffercache/pg_buffercache_pages.c Outdated

@ashutosh-bapat ashutosh-bapat left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you address a comment, please describe the resolution as a response to the comment. It seems there are some review comments still remain unaddressed.

Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
Comment thread contrib/pg_buffercache/pg_buffercache_pages.c Outdated
Comment thread contrib/pg_buffercache/t/001_basic.pl
Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
# Wake up buffercache scan
$node->safe_psql('postgres', "SELECT injection_points_wakeup('$buffercache_injection_point')");

$buffercache_session->query(q(\echo 'done'));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you addressed this comment?

#include "utils/rel.h"
#include "utils/tuplestore.h"


Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary line removal. PostgreSQL code usually leaves an extra line between #include section and rest of the code.

Comment thread contrib/pg_buffercache/pg_buffercache_pages.c Outdated
int max_entries;
char *startptr,
*endptr;
int currentNBuffers = pg_atomic_read_u32(&ShmemCtrl->currentNBuffers);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this change and other changes which use currentNBuffers variable?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a buffer scan loop which should be change to currentNBuffers

Comment thread contrib/pg_buffercache/Makefile Outdated
Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
shared_preload_libraries = 'injection_points'
max_shared_buffers = $shared_buffers_initial
shared_buffers = $shared_buffers_initial
max_parallel_workers_per_gather = 0

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need max_parallel_workers_per_gather in the test?

Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
$injection_session->query_safe("SELECT injection_points_attach('$injection_point', 'wait')", verbose => $verbose);

# Create a new session for resize
my $resize_session = $node->background_psql('postgres');

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to do this? Isn't existing resize_session enough?

Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
note("buffercache query error during $test_name ($operation_type): $query_err") if $query_err;
$buffercache_session->{stderr} = '';

eval { $buffercache_session->quit; };

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need eval{} here?

Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
eval { $buffercache_session->quit; };

# Detach injection point
eval {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need eval[] here?

Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
Comment thread contrib/pg_buffercache/t/001_basic.pl Outdated
verbose => $verbose);

my ($buffercache_output, $buffercache_err);
eval { ($buffercache_output, $buffercache_err) = $buffercache_session->query(q(\echo 'done')); };

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need eval{} here?

…pages.c

Revert NBuffers -> currentNBuffers changes in pg_buffercache_os_pages_internal,
pg_buffercache_summary, and pg_buffercache_usage_counts as requested by
reviewer (comments #7, #15, #22). Only injection point additions and the
coupled currentNBuffers change in pg_buffercache_evict are retained.

Also fix typo 'curent' -> 'current' in TODO comment, restore missing
newline at EOF, and improve test file: add scan count validation,
use query_safe consistently, clean up session handling and comments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants