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

Home Posts Topics Members FAQ

pg_class and relfilenode

Hi,

I am currently having the corrupted tables issues
described in the following link (possibly caused by
power failure, which happens pretty often)
http://archives.postgresql.org/pgsql...4/msg00012.php.
Since we have our systems being deployed to numerous
remote systems (psql 7.2.3), upgrading the entire database
(with data migration) will be the least preferable
solution. I am thinking of creating a script that
periodically check the relfilenode inside the pg_class
and if there is any mismatch between what pg_class
described and what actually exists in the file system,
the script will touch that file and try to drop the
table. However, after I wrote the script and started
testing it, I found that there are already some files
(mainly pg_*) tables/indexes are not being consistent
with the filesystem.

e.g.
pg_shadow_usena me_index
pg_stat_activit y
pg_stat_databas e

And my script look something like:
select oid, * from pg_database where datname = <db>
select oid, relname from pg_class
and touch <base>/DB#/FILE# for everything found
inside pg_class if it doesn't exist on the file system.

Is it going to harm the database
if I blindly touch those files? Or is there any
workaround/trick/patch I can apply to version 7.2.3
without upgrading the whole database? Something like a
patch/trick which can force drop a table will be my main
goal.

Thanks,

--muteki

_______________ _______________ _______________ _______________ _____
Create your own personal Web page with the info you use most, at My MSN.
http://click.atdmt.com/AVE/go/onm00200364ave/direct/01/
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 22 '05 #1
3 3624
> e.g.
pg_shadow_usena me_index
pg_stat_activit y
pg_stat_databas e


They are system views and correspond to no file.
See PostgreSQL's documents.

Nov 22 '05 #2
On Tue, Feb 10, 2004 at 08:29:50PM -0800, muteki muteki wrote:
Hi,

I am currently having the corrupted tables issues
described in the following link (possibly caused by
power failure, which happens pretty often)
http://archives.postgresql.org/pgsql...4/msg00012.php.
Since we have our systems being deployed to numerous
remote systems (psql 7.2.3), upgrading the entire database
(with data migration) will be the least preferable
solution. I am thinking of creating a script that


You don't need to do any data migration to get off 7.2.3 -- 7.2.4 is
a drop-in replacement, so you should at least do that upgrade first.

But I don't think that power failures would be enough to cause the
kind of problem you're describing, unless you're running without
fsync or something. Care to give more details?

In any case, I think that your script is mighty dangerous. It sounds
like a recipe for data loss to me. Postgres is considerably more
robust than this, and I think you're trying to cover up some serious
problems that you may have, likely with your hardware.

A
--
Andrew Sullivan

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 22 '05 #3
"muteki muteki" <mu******@hotma il.com> writes:
Since we have our systems being deployed to numerous
remote systems (psql 7.2.3), upgrading the entire database
(with data migration) will be the least preferable
solution.
At the very least you should be running 7.2.4. We do not make
dot-releases for entertainment value, we make them because there
are critical bug fixes. In particular, this 7.2.4 fix:
* Ensure pg_clog updates are sync'd to disk before marking checkpoint complete
might well have something to do with your problems.
I found that there are already some files
(mainly pg_*) tables/indexes are not being consistent
with the filesystem. e.g.
pg_shadow_usena me_index
pg_stat_activit y
pg_stat_databas e


Views don't have underlying files at all. Shared tables live in a
different directory. You had better study the system catalogs more
carefully before you start writing scripts to hack them.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 22 '05 #4

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

Similar topics

0
1717
by: Jeff Boes | last post by:
Is there any way to distinguish temporary tables from "regular" ones by the contents of pg_class (or some other table of metadata)? (I'm using PG 7.3.4.) -- Jeff Boes vox 269.226.9550 ext 24 Database Engineer fax 269.349.9076 Nexcerpt, Inc. http://www.nexcerpt.com ...Nexcerpt... Extend your Expertise
1
2032
by: Thomas Bamesberger | last post by:
Hi, yes i know, this question has already been asked and i found it in the archives, but i didnt find an answer for this problem, so maybe one of you can help me? My PostgreSQL Database has been up and running exactly for one year, but last week after rebooting the error message "fixrdesc: no pg_class entry for pg_class" appeared on the screen. So is there any way to solve this problem or to recover the data at least?
0
2850
by: Tom Hebbron | last post by:
Hi list, test=# SELECT 'pg_catalog.pg_class'::regclass::oid; oid ------ 1259 (1 row) test=# SELECT '1259'::oid::regclass; regclass
0
1132
by: Brian Hirt | last post by:
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...
1
3499
by: Gregory Stone | last post by:
I've got a problem where any group or user permissions to the pg_class table aren't being registered by either psql or the JDBC driver. I issue the following command: GRANT ALL ON TABLE pg_class TO GROUP apps; -OR- GRANT ALL ON TABLE pg_class TO sculptor; Both apps and sculptor are valid user and group names respectively. The command executes fine and the following query produces:
1
1816
by: Sally Sally | last post by:
Very strange things are happening when I am reindexing a table. I did this with postmaster running as a standalone. The index for the table prior to reindexing is on a separate disk and I created a sym link (due to lack of space). When the reindexing is done I see new files created under /data/base/dbnumber/ but when I look at pg_class table it is pointing still to the old index because the oid I get is the older one. What does this mean?...
8
2523
by: zhicheng wang | last post by:
hi, has any one used Martijn van Oosterhout's PostgreSQL table checker and dumper (pgfsck, at http://svana.org/kleptog/pgsql/pgfsck.html)? i ran this again my database and it gives this error: Couldn't find relation pg_class(1259)
1
2548
by: Ed L. | last post by:
While dealing with filesystem bloat issues, I found a large file named 43710738, recently updated and sitting in one of my database directories, $ ls -lh ../../../data/base/11259315/43710738 -rw------- 1 dba dba 1016M Nov 3 17:05 ../../../data/base/11259315/43710738 .... with no corresponding entry that I can find in pg_class with that oid (I thought they were all in there). I tried dumping the database, knowing the...
0
936
by: randyocc | last post by:
I am replicating a table via slony. I know the relfilenode of the table from pg_class but a new disk file is created with a different relfilenode. After the copy is complete, the relfilenode for the table is updated with the new number. Is there a way to know the "temporary" or "new" number while it is copying? For example, table xxx is being replicated from node 1 to node 2. The relfilenode from pg_class on node 2 for table xxx is...
0
8443
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
8356
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,...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8639
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7385
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...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
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
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.