473,411 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

fairly serious bug with pg_autovacuum in pg7.4

Hello,

I've run across a pretty serious problem with pg_autovacuum.
pg_autovacuum looses track of any table that's ever been truncated
(possibly other situations too). When i truncate a table it gets a
new relfilenode in pg_class. This is a problem because pg_autovacuum
assumes pg_class.relfilenode will join to pg_stats_all_tables.relid.
pg_stats_all_tables.relid is actallly the oid from pg_class, not the
relfilenode. These two values start out equal so pg_autovacuum works
initially, but it fails later on because of this incorrect assumption.

here is one query pg_autovacuum uses (from pg_autovacuum.h) to get
tables that breaks.

select
a.relfilenode,a.relname,a.relnamespace,a.relpages, a.relisshared,a.reltup
les,b.schemaname,b
..n_tup_ins,b.n_tup_upd,b.n_tup_del from pg_class a, pg_stat_all_tables
b where a.relfilenode=b.relid and a.relkind = 'r'
here's a little test case you can use to see what happens:

basement=# create table test_table ( id int4 );
CREATE TABLE
basement=# select relname, relfilenode from pg_class where relkind =
'r' and relname = 'test_table';
relname | relfilenode
------------+-------------
test_table | 28814151
(1 row)

basement=# select relid,relname from pg_stat_all_tables where relname =
'test_table';
relid | relname
----------+------------
28814151 | test_table
(1 row)

basement=# select
a.relfilenode,a.relname,a.relnamespace,a.relpages, a.relisshared,a.reltup
les,b.schemaname,
basement-# b.n_tup_ins,b.n_tup_upd,b.n_tup_del from pg_class a,
pg_stat_all_tables b
basement-# where a.relfilenode=b.relid and a.relkind = 'r' and
a.relname = 'test_table';
relfilenode | relname | relnamespace | relpages | relisshared |
reltuples | schemaname | n_tup_ins | n_tup_upd | n_tup_del
-------------+------------+--------------+----------+-------------
+-----------+------------+-----------+-----------+-----------
28814151 | test_table | 2200 | 10 | f |
1000 | public | 0 | 0 | 0
(1 row)

basement=#
basement=# truncate table test_table;
TRUNCATE TABLE
basement=# select relname, relfilenode from pg_class where relkind =
'r' and relname = 'test_table';
relname | relfilenode
------------+-------------
test_table | 28814153
(1 row)

basement=# select relid,relname from pg_stat_all_tables where relname =
'test_table';
relid | relname
----------+------------
28814151 | test_table
(1 row)

basement=# select
a.relfilenode,a.relname,a.relnamespace,a.relpages, a.relisshared,a.reltup
les,b.schemaname,
basement-# b.n_tup_ins,b.n_tup_upd,b.n_tup_del from pg_class a,
pg_stat_all_tables b
basement-# where a.relfilenode=b.relid and a.relkind = 'r' and
a.relname = 'test_table';
relfilenode | relname | relnamespace | relpages | relisshared |
reltuples | schemaname | n_tup_ins | n_tup_upd | n_tup_del
-------------+---------+--------------+----------+-------------
+-----------+------------+-----------+-----------+-----------
(0 rows)

basement=# drop table test_table;
DROP TABLE
basement=#
PS: i'm running pg-7.4 and pg_autovacuum from contrib.
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #1
0 1118

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Adam Kavan | last post by:
I decided to try pg_autovacuum and am having a problem. It never analyzes or vacuums. I looked at the code and had it display printf("%s,%s,%s\n",PQgetvalue(res, j, PQfnumber(res,...
5
by: Frank van Vugt | last post by:
Hi, I noticed that when using the single commandline: drop database <name>; create database <name>; this sometimes fails due to a pg_autovacuum process running on the background. When...
3
by: Markus Wollny | last post by:
Hi! I haven't found anything in terms of startup- and check-scripts for pg_autovacuum yet; usually I like to have some sort of mechanism to check if some daemon is running and restart it if it...
4
by: David Wheeler | last post by:
4.8-STABLE FreeBSD 4.8-STABLE i386 sahlins# cd postgresql-7.4.2/contrib/pg_autovacuum sahlins# make "../../src/Makefile.global", line 38: Missing dependency operator...
3
by: Brian Hirt | last post by:
I've having a strange issue with pg_autovacuum. I have a table with about 4 million rows in 20,000 pages. autovacuum likes to vacuum and/or analyze it every 45 minutes or so, but it probably...
2
by: Peter Haworth | last post by:
Is it possible/safe to compile the latest version of pg_autovacuum, and use it with a 7.2.4 postmaster? I know the better solution would be to upgrade everything, but that involves a lot of work...
7
by: Thomas F.O'Connell | last post by:
I'm about to try to implement a simple pg_autovacuum script that can be used in conjunction with or integrated entirely with the contrib start-scripts for postgres. I just want to check that what...
2
by: Oliver Elphick | last post by:
I get this in the logs for every database open by pg_autovacuum: Sep 1 14:02:45 cerberus pg_autovacuum: nss_ldap: could not connect to any LDAP server as (null) - Can't contact LDAP server ...
5
by: Thomas F.O'Connell | last post by:
I've been using pg_autovacuum on a largish postgres installation successfully for several weeks, now. I know that pg_autovacuum has no facility for monitoring the system to know whether any...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.