Subject: Re: Cannot turn track_counts on

From: Anton Shepelev <[email-masked]>
Date: Fri, 18 Apr 2025 00:23:07 +0300

Adrian Klaver to Anton Shepelev:

> >    db=# show shared_preload_libraries;
> >     shared_preload_libraries
> >    ---------------------------
> >     online_analyze, plantuner
>
> Are you running PostgresPro?
>
> Both those modules are associated with it:
>
> https://postgrespro.com/docs/postgrespro/17/contrib.html

Not at all.  Whereas `pg_config --version' answers with an
irrelevant quip:

   You need to install postgresql-server-dev-NN for building
   a server-side extension or libpq-dev for building a
   client-side application.

The version() SQL function returns:

   PostgreSQL 11.21 (Debian 1:11.21-astra.se6+ci1)
   on x86_64-pc-linux-gnu,
   compiled by gcc (AstraLinuxSE 8.3.0-6) 8.3.0, 64-bit

I will test if clearing shared_preload_libraries and
restarting Postgres has any effect on track_counts, just in
case.

-- 
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments

---

From: Adrian Klaver <[email-masked]>
Date: Thu, 17 Apr 2025 14:44:39 -0700

> Not at all.  Whereas `pg_config --version' answers with an

The below does not look like a Postgres message to me.

>     a server-side extension or libpq-dev for building a

How was this Postgres instance installed or built?

>     compiled by gcc (AstraLinuxSE 8.3.0-6) 8.3.0, 64-bit

Not seeing how the above is matching up with:

https://en.wikipedia.org/wiki/Astra_Linux

-- 
Adrian Klaver
[email-masked]

---

From: Anton Shepelev <[email-masked]>
Date: Fri, 18 Apr 2025 01:25:57 +0300

Adrian Klaver to Anton Shepelev:

> > You need to install postgresql-server-dev-NN for
> > building a server-side extension or libpq-dev for
> > building a client-side application.

Yet that is what we get for `pg_config --version' on the
affected system.  A nearly identical error message seems to
come up while installing psycopg2 -- a Python library for
Postgres, e.g.:

   <https://stackoverflow.com/q/28253681/2862241>
   <https://www.matheusmello.io/posts/python-you-need-to-install-postgresql-server-dev-x-y-for-building-a-server-side-extensi>

I have not the slightest idea why pg_config should print
this message, unless it is not a genuine pg_config.  I will
be checking its binary against the one that works as expected
on our reference system.

> How was this Postgres instance installed or built?

Installed from Astra Linux's native repository:

   ant@xx:~$ apt list postgresql-11
   Listing... Done
   postgresql-11/stable,stable,now 1:11.21-astra.se6+ci1 amd64 [installed]

> https://en.wikipedia.org/wiki/Astra_Linux

Do you mean 8.3.0-6?  It looks like the GCC version. Our
Astra is 1.7.5:

   ant@xx:~$ cat /etc/issue
   Astra Linux 1.7.5 \n \l

---

From: Adrian Klaver <[email-masked]>
Date: Fri, 18 Apr 2025 08:32:50 -0700

> be checking its binary against the one that works as expected

Found it. It is coming from the Debian postgresql-common packaging.

/usr/bin/pg_config  is  wrapper that contains:

#!/bin/sh

# If postgresql-server-dev-* is installed, call pg_config from the latest
# available one. Otherwise fall back to libpq-dev's version.
#
# (C) 2011 Martin Pitt <[email-masked]>
# (C) 2014-2018 Christoph Berg <[email-masked]>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.

set -e
PGBINROOT="/usr/lib/postgresql/"
#redhat# PGBINROOT="/usr/pgsql-"
LATEST_SERVER_DEV=`ls -v $PGBINROOT*/bin/pg_config 2>/dev/null|tail -n1`

if [ -n "$LATEST_SERVER_DEV" ]; then
     exec "$LATEST_SERVER_DEV" "$@"
else
     if [ -x /usr/bin/pg_config.libpq-dev ]; then
         exec /usr/bin/pg_config.libpq-dev "$@"
     else
         echo "You need to install postgresql-server-dev-NN for building 
a server-side extension or libpq-dev for building a client-side 
application." >&2
         exit 1
     fi
fi

The message is telling you that on the machine you ran pg_config you 
have not installed either:

postgresql-server-dev-X where X is a major version

or

libpq-dev

If you want to get information from pg_config you will need to install 
one or the other. I would suggest libpq-dev.

---

From: Anton Shepelev <[email-masked]>
Date: Mon, 21 Apr 2025 19:26:55 +0300

> # available one. Otherwise fall back to libpq-dev's version.

Ah, that makes sense.  The error message, however, is
misleading:

  You need to install postgresql-server-dev-NN
  for building a server-side extension
  or libpq-dev
  for building a client-side application.

because the user calling `pg_config' may not be intent upon
buidling either kind of application.  Stating that pg_config
requires one of these pachages would be more understandable.
Thank you very much.

---

From: Anton Shepelev <[email-masked]>
Date: Mon, 21 Apr 2025 19:46:44 +0300

I wrote:

> restarting Postgres has any effect on track_counts, just
> in case.

Nope, it didn't unstick track_counts:

  db=# show shared_preload_libraries ;
  -[ RECORD 1 ]------------+-
  shared_preload_libraries |

  db=# select * from pg_settings where name like '%k_cou%';
  -[ RECORD 1 ]---+--------------------------------------------------
  name            | track_counts
  setting         | off
  unit            |
  category        | Statistics / Query and Index Statistics Collector
  short_desc      | Collects statistics on database activity.
  extra_desc      |
  context         | superuser
  vartype         | bool
  source          | override
  min_val         |
  max_val         |
  enumvals        |
  boot_val        | on
  reset_val       | off
  sourcefile      |
  sourceline      |
  pending_restart |

Have you any further ideas how to turn track_counts on?

---

From: Adrian Klaver <[email-masked]>
Date: Mon, 21 Apr 2025 09:47:46 -0700

> requires one of these pachages would be more understandable.

That is a request for the Debian packaging team.

They can be reached at:

https://www.postgresql.org/list/pgsql-pkg-debian/

Or through alternate means as detailed here:

https://wiki.postgresql.org/wiki/Apt#Bugs

---

From: Adrian Klaver <[email-masked]>
Date: Mon, 21 Apr 2025 09:52:34 -0700

> Have you any further ideas how to turn track_counts on?

It is matter of finding out what is setting?:

source          | override

There is something different about your setup, as here on Ubuntu(which 
uses the Debian packaging) I see:

select * from pg_settings where name like '%k_cou%';

-[ RECORD 1 ]---+---------------------------------------------------
name            | track_counts
setting         | on
unit            | NULL
category        | Statistics / Cumulative Query and Index Statistics
short_desc      | Collects statistics on database activity.
extra_desc      | NULL
context         | superuser
vartype         | bool
source          | default
min_val         | NULL
max_val         | NULL
enumvals        | NULL
boot_val        | on
reset_val       | on
sourcefile      | NULL
sourceline      | NULL
pending_restart | f

---

From: Anton Shepelev <[email-masked]>
Date: Tue, 22 Apr 2025 11:31:30 +0300

Adrian Klaver:

> Anton Shepelev:

Indeed, I having begun with this crucial question.

> There is something different about your setup, as here on
> Ubuntu(which uses the Debian packaging) I see:
> [...]

Yes.  It is on on your side, and pgsql shows NULL values as
NULL.  Can the latter be due to a differnce in Postgres
versions, for mine is 11.21 (as I have reported before)?

We have several other servers with identical versions of the
OS and PostgreSQL:

  user@DC:/opt/sva$ cat /etc/issue
  Astra Linux 1.7.5
  user@xx:/opt/sva$ apt show postgresql
  Package: postgresql
  Version: 11+225astra3
  Priority: optional
  Section: database
  Source: postgresql-common (225astra3)
  Maintainer: Debian PostgreSQL Maintainers <[email-masked]>

  user@xx:/opt/sva$ psql -V
  psql (PostgreSQL) 11.21 (Debian 1:11.21-astra.se6+ci1)

but `track_counts' is stuck off only on one.

A complete reinstall with purging of all configuration data
comes to mind, but it is a last-resort measure, as the
system is a production one, and actively used.

---

From: Adrian Klaver <[email-masked]>
Date: Tue, 22 Apr 2025 08:21:09 -0700

> versions, for mine is 11.21 (as I have reported before)?

No that is because I have my ~/.psqlrc set up with:

\pset null 'NULL'

 From here:

https://www.postgresql.org/docs/current/app-psql.html

See the:

Meta-Commands
\pset

section

as well as

Files

psqlrc and ~/.psqlrc

> system is a production one, and actively used.

Given that the Debian Postgres packaging allows you to install multiple 
clusters of a given version I would create a new 11.21 cluster as a test 
and see what track_counts is set to. That would help determine whether 
the setting is coming from the initial install. You could then add the 
other components to the cluster one by one and see if and where the 
track_counts setting changes.