> I had defined the foreign key to cascade on delete, and I imagine that
> during the dump the delete occurred on the master table. Perhaps the
> keyed table had already been dumped so when it came time to dump the
> master table, the referencing row was not there to be dumped.
pg_dump does all its work in a single serializable transaction to avoid
this sort of problem. It doesn't see any changes made to the database
after it starts. So, assuming you used pg_dump to dump the database as a
whole rather than invoking it separately for a bunch of separate tables,
that should not be your problem.
How do you run pg_dump? Can you supply the script or command line?
> One would
> imagine that PostgreSQL would have protections for that sort of thing...
It does, which is what makes the issue you've encountered somewhat strange.
--
Craig Ringer
--
Sent via pgsql-general mailing list (pgsql-...@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
One thing that comes to mind is to restore the dump file to a file instead of a
database and see what is being dumped from the live database.
--
Adrian Klaver
akl...@comcast.net
he meant...
pg_restore -f outputfile.sql yourdumpfile
this will convert the dumpfile to SQL...
----- "CG" <cgg...@yahoo.com> wrote:
> Thanks for the suggestion. I'm not sure what you mean when you say I
> should restore to a file. Do you mean I should dump the database to an
> SQL file instead of the "compressed" format?
See Johns answer.
>
> What do you think I will find?
>
> In the database dump, it is including a row that should be marked as
> deleted. I can select on that key in the production database and get
> zero rows, and I can select on that key in the restored database and
> find the row. When I ignore errors the data is restored, but the
> foreign key can't be created (and that is the only error I encounter).
> The presence of the data in the dump can not be contested... :)
>
Well I often find what I 'know' and what is are not the same:) Basically restoring to the file replicates the database restore, with out the error hopefully. Looking at the data restored in the file might give you a clue to what is going on. Just one step in the process of resolving the problem.
Adrian Klaver
akl...@comcast.net
Just so I am clear it always exactly the same UUID that shows up in the dump
file? Upstream in this thread you mentioned a DELETE trigger that copied
deleted items to another table. Is it possible that there is a stuck query
related to this trigger that is keeping this row visible to pg_dump? A query
against pg_stat_activity might be useful.
--
This could be a corrupted index problem maybe? If you do this:
set enable_indexscan=off;
select * from table where key=value;
does it still not show up?