Re: Accessing Database files on a "read-only" medium...like

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Kelly Harmon <kelly(dot)harmon(at)byers(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Accessing Database files on a "read-only" medium...like
Date: 2001-10-12 18:21:03
Message-ID: 200110121821.f9CIL3j14632@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


I wonder if you shut down the postmaster and restart if that would make
it work again. I can't imagine where it would store table size
information if the area is read-only. Adding data, full vacuum, restart
postmaster should allow read-only databases.

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

> I'm curious as to whether anybody has gotten PostgreSQL to work with a
> database that lives on some sort of read-only medium...like a CD.
>
> I've looked around in the newsgroups and I've seen a comment by Bruce
> Momjian that it can't currently be done...and I've seen a different comment
> by Tom Lane that he thought that it probably could...So...I dunno.
>
> I've taken a database and set the read-only attributes on its files and
> tried to access it via psql...and couldn't...it complained about not being
> able to open pg_class.
>
> SO...I dug around through the code a little and found where the error was
> coming from and changed the code so that if the open attempt with O_RDWR
> fails, the code tries again with O_RDONLY. This was in md.c...in the mdopen
> function.
>
> This did work....I was then able to open the database and do queries and
> whatnot. Trying to insert into the table didn't give any errors...until I
> tried to select the record back out, at which time it started giving me
> errors such as:
>
> ERROR: cannot write block 7548 of pole: Permission denied
>
> At that point, it seems that your screwed...in that even if you shut down
> postgres and restart it, somewhere it knows that that database has data that
> needs to be written to disk, and it refuses to continue until it does so.
>
> OTHER than that one problem...Is anyone aware of any other problems that my
> change might cause? To be really useful, it would be necessary to go
> through and make additional changes so that it can recover from a failed
> write to the "read-only" database. But it seems like it would be okay as
> long as you carefully avoid changing the database.
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-10-12 18:27:56 Re: SQL99 time zones
Previous Message Bruce Momjian 2001-10-12 17:54:09 Re: PG_DUMP NLS (Russian)