Diagnostic functions

Started by Heikki Linnakangasabout 19 years ago8 messagespatches
Jump to latest
#1Heikki Linnakangas
heikki.linnakangas@enterprisedb.com

Here's an update of Simon's Heap Page Diagnostic Functions. I now
consider it ready to commit.

The new functions are all under new contrib module,
contrib/pgdiagnostics. I also moved bt_metap, bt_page_items and
bt_page_stats from pgstattuple to the new module.

I copied the bt_* functions almost unmodified. I didn't try to harmonize
the user interface or return values with the new heap page functions,
though that might we worth doing in the future.

I added input value checking to the new functions so that they should
handle invalid data gracefully. All the new functions are nevertheless
superuser-only, just to err on the safe side.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

Attachments:

pgdiagnostics.patchtext/x-diff; name=pgdiagnostics.patchDownload+1215-617
#2Peter Eisentraut
peter_e@gmx.net
In reply to: Heikki Linnakangas (#1)
Re: Diagnostic functions

Heikki Linnakangas wrote:

Here's an update of Simon's Heap Page Diagnostic Functions. I now
consider it ready to commit.

How is this better than pg_filedump?

"diagnostics" is an awfully general name, too.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#3Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Peter Eisentraut (#2)
Re: Diagnostic functions

Peter Eisentraut wrote:

Heikki Linnakangas wrote:

Here's an update of Simon's Heap Page Diagnostic Functions. I now
consider it ready to commit.

How is this better than pg_filedump?

It's handy to be able to inspect pages from within a live database. The
new functions work through shared_buffers, so you can see changes
without having to issue a checkpoint to flush them to disk. pg_filedump
takes a filename as argument, the new function takes relation name.

Having them as functions also allows you to do more advanced queries
like "... WHERE (t_infomask & 1) <> 0 " to show tuples with a null bitmap.

"diagnostics" is an awfully general name, too.

We already played the name game on hackers. My original suggestion was
"pgforensics". "pgdiagfuncs" and "pginspect" were also suggested, among
others. I'm still open to suggestions, though. Have any?

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

#4Peter Eisentraut
peter_e@gmx.net
In reply to: Heikki Linnakangas (#3)
Re: Diagnostic functions

Am Montag, 7. Mai 2007 11:49 schrieb Heikki Linnakangas:

It's handy to be able to inspect pages from within a live database.

How reliable is it to inspect pages from within a database if you presumably
suspect that database to be broken?

We already played the name game on hackers. My original suggestion was
"pgforensics". "pgdiagfuncs" and "pginspect" were also suggested, among
others. I'm still open to suggestions, though. Have any?

Something involving "page" would at least explain what you can diagnose.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#5Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Peter Eisentraut (#4)
Re: Diagnostic functions

Peter Eisentraut wrote:

Am Montag, 7. Mai 2007 11:49 schrieb Heikki Linnakangas:

It's handy to be able to inspect pages from within a live database.

How reliable is it to inspect pages from within a database if you presumably
suspect that database to be broken?

As long as the page header is valid, the functions should be able to
deal with it (as in not crashing).

I found them extremely useful when I was developing the MVCC-safe
CLUSTER patch. The index functions in pgstattuple were very useful when
I worked on clustered indexes. In fact I reinvented the wheel and wrote
a function of my own that did essentially the same thing as
bt_page_items, before Bruce pointed out that such a thing already exists.

We already played the name game on hackers. My original suggestion was
"pgforensics". "pgdiagfuncs" and "pginspect" were also suggested, among
others. I'm still open to suggestions, though. Have any?

Something involving "page" would at least explain what you can diagnose.

Well, how about "pageinspect" then?

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

#6Bruce Momjian
bruce@momjian.us
In reply to: Heikki Linnakangas (#5)
Re: Diagnostic functions

Heikki Linnakangas wrote:

We already played the name game on hackers. My original suggestion was
"pgforensics". "pgdiagfuncs" and "pginspect" were also suggested, among
others. I'm still open to suggestions, though. Have any?

Something involving "page" would at least explain what you can diagnose.

Well, how about "pageinspect" then?

Sounds good to me.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#7Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Bruce Momjian (#6)
Re: Diagnostic functions

Bruce Momjian wrote:

Heikki Linnakangas wrote:

We already played the name game on hackers. My original suggestion was
"pgforensics". "pgdiagfuncs" and "pginspect" were also suggested, among
others. I'm still open to suggestions, though. Have any?

Something involving "page" would at least explain what you can diagnose.

Well, how about "pageinspect" then?

Sounds good to me.

Ok, here's an updated patch. It's the same as the last one, except for
the name.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

Attachments:

pageinspect.patchtext/x-diff; name=pageinspect.patchDownload+1216-617
#8Bruce Momjian
bruce@momjian.us
In reply to: Heikki Linnakangas (#7)
Re: Diagnostic functions

Applied. I also updated /contrib/README. Thanks.

---------------------------------------------------------------------------

Heikki Linnakangas wrote:

Bruce Momjian wrote:

Heikki Linnakangas wrote:

We already played the name game on hackers. My original suggestion was
"pgforensics". "pgdiagfuncs" and "pginspect" were also suggested, among
others. I'm still open to suggestions, though. Have any?

Something involving "page" would at least explain what you can diagnose.

Well, how about "pageinspect" then?

Sounds good to me.

Ok, here's an updated patch. It's the same as the last one, except for
the name.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +