473,799 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.relfil enode will join to pg_stats_all_ta bles.relid.
pg_stats_all_ta bles.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.reln amespace,a.relp ages,a.relissha red,a.reltup
les,b.schemanam e,b
..n_tup_ins,b.n _tup_upd,b.n_tu p_del from pg_class a, pg_stat_all_tab les
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_tab les where relname =
'test_table';
relid | relname
----------+------------
28814151 | test_table
(1 row)

basement=# select
a.relfilenode,a .relname,a.reln amespace,a.relp ages,a.relissha red,a.reltup
les,b.schemanam e,
basement-# b.n_tup_ins,b.n _tup_upd,b.n_tu p_del from pg_class a,
pg_stat_all_tab les 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_tab les where relname =
'test_table';
relid | relname
----------+------------
28814151 | test_table
(1 row)

basement=# select
a.relfilenode,a .relname,a.reln amespace,a.relp ages,a.relissha red,a.reltup
les,b.schemanam e,
basement-# b.n_tup_ins,b.n _tup_upd,b.n_tu p_del from pg_class a,
pg_stat_all_tab les 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 1141

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

Similar topics

11
1890
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, "n_tup_ins")),PQgetvalue(res, j, PQfnumber(res, "n_tup_upd")),PQgetvalue(res, j, PQfnumber(res, "n_tup_del"))); All of these values are always 0 for all tables irregardless of activity on the tables. Any clue what could be causing this? In postgresql.conf...
5
3277
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 this happens, the error returned is:
3
2737
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 isn't. Of course this sort of script shouldn't be too much of a bother for more experienced users; however you might actually find this small checkup-script more or less useful - just save it in /opt/pgsql/bin/ as autovachk, chmod +x and follow...
4
1813
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 "../../src/Makefile.global", line 41: Need an operator "../../src/Makefile.global", line 45: Need an operator "../../src/Makefile.global", line 66: Need an operator "../../src/Makefile.global", line 67: Need an operator "../../src/Makefile.global", line 69: Need an...
3
1289
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 doesn't have more that a few hundred rows changed every few hours. when i run autovacuum with -d3 it says table name: basement_nightly."public"."search_words4" relid: 396238832; relisshared: 0 reltuples: 4; relpages: 20013
2
1236
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 which we've managed to put off for a long time already, and autovacuum is pretty much the only feature we really need immediately. -- Peter Haworth pmh@edison.ioppublishing.com "There are two ways of constructing a software design. One way is...
7
1822
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 I'm doing has the appropriate sanity checks. The behavior I'm considering is: if pg_ctl status returns a good value then if pg_autovacuum is not running then start pg_autovacuum
2
1375
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 This is produced by the bind_to() call in libnss-ldap. This is invoked when /etc/nss_switch.conf specifies ldap; what I don't understand yet is what pg_autovacuum is doing differently from every other application so as to cause this message.
5
1720
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 particular time is a good one for it to do it's thing, but I'm wondering what the occasional episodes of 99.9% CPU usage (as reported by top) are. I keep a pg_autovacuum.log, and when the spikes start, often nothing is written to the log. And what...
0
9689
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10248
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9085
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7573
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.