Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

broken postgresql plugins on PostgreSQL 17 #1483

Open
okbob opened this issue Feb 20, 2025 · 0 comments
Open

broken postgresql plugins on PostgreSQL 17 #1483

okbob opened this issue Feb 20, 2025 · 0 comments

Comments

@okbob
Copy link

okbob commented Feb 20, 2025

Hi

we did upgrade to PostgreSQL 17, and we found broken plugins PotgreSQL bgwriter and PostgreSQL checkpoints.
The system view pg_stat_bgwriter was changed by commit postgres/postgres@96f0526

The queries fails with errors

column "buffers_checkpoint" does not exist
column "checkpoints_timed" does not exist

The query

SELECT buffers_checkpoint,buffers_clean,buffers_backend,buffers_alloc FROM pg_stat_bgwriter

should be rewritten to

SELECT pg_stat_get_checkpointer_buffers_written() as buffers_checkpoint,
              buffers_clean,
              pg_stat_get_checkpointer_buffers_written() as buffers_backend,
              buffers_alloc
  FROM pg_stat_bgwriter

The query

SELECT row_to_json (T)
  FROM (
              SELECT  checkpoints_timed
                          , checkpoints_req
                          , checkpoint_write_time
                          , checkpoint_sync_time
                          , buffers_checkpoint
                          , buffers_clean
                          , maxwritten_clean
                          , buffers_backend
                          , buffers_backend_fsync
                          , buffers_alloc
              FROM pg_catalog.pg_stat_bgwriter) T;

should be rewritten to

SELECT row_to_json (T)
 FROM (
   SELECT
         num_timed as checkpoints_timed
       , num_requested as checkpoints_req
       , write_time as checkpoint_write_time
       , sync_time as checkpoint_sync_time
       , buffers_written as buffers_checkpoint
       , pg_stat_get_bgwriter_buf_written_clean() as buffers_clean
       , pg_stat_get_bgwriter_maxwritten_clean() as maxwritten_clean
       , buffers_written as buffers_backend
       , 0 as buffers_backend_fsync
       , pg_stat_get_buf_alloc() as buffers_alloc
    FROM pg_catalog.pg_stat_checkpointer) T;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant