pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Pg_restore failing due to data inconsistency in dump file
7+ messages / 4 participants
[nested] [flat]

* Pg_restore failing due to data inconsistency in dump file
@ 2018-12-13 11:20  soumitra bhandary <soumitra.bhandary@hotmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: soumitra bhandary @ 2018-12-13 11:20 UTC (permalink / raw)
  To: pgsql-admin

Hello Team ,

I have encountered following issue while restoring the Postgres dump using pg_restore . Please provide any suggestion to the same .

  1.  This dump was taken using bdr_dump as bdr enabled database and all the BDR configuration and extension was excluded .
  2.  DUMP was taken in a running DB server where BDR was running .
  3.  Postgres Dump was taken in .dump format .
  4.  During restoration of the same using pg_restore getting following error .

Error :

pg_restore: [archiver (db)] Error from TOC entry 3061; 2606 17551 FK CONSTRAINT fk_5hrm2vlf9ql5fu043kqepovbr DBNAME
pg_restore: [archiver (db)] could not execute query: ERROR: insert or update on table "user_attribute" violates foreign key constraint "fk_5hrm2vlf9ql5fu043kqepovbr"
DETAIL: Key (user_id)=(1f34ec07-7087-45ff-8a56-f36177752499) is not present in table "user_entity".
Command was: ALTER TABLE ONLY user_attribute
ADD CONSTRAINT fk_5hrm2vlf9ql5fu043kqepovbr FOREIGN KEY (user_id) REFERENCES user_entity...
pg_restore: [archiver (db)] Error from TOC entry 3065; 2606 17601 FK CONSTRAINT fk_c4fqv34p1mbylloxang7b1q3l DBNAME
pg_restore: [archiver (db)] could not execute query: ERROR: insert or update on table "user_role_mapping" violates foreign key constraint "fk_c4fqv34p1mbylloxang7b1q3l"
DETAIL: Key (user_id)=(24d1ee2a-b05e-4c30-a292-84045c47611e) is not present in table "user_entity".


Thanks ,

Soumitra

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Pg_restore failing due to data inconsistency in dump file
@ 2018-12-13 12:21  Shreeyansh Dba <shreeyansh2014@gmail.com>
  parent: soumitra bhandary <soumitra.bhandary@hotmail.com>
  0 siblings, 2 replies; 7+ messages in thread

From: Shreeyansh Dba @ 2018-12-13 12:21 UTC (permalink / raw)
  To: soumitra.bhandary@hotmail.com; +Cc: pgsql-admin

Hi Soumitra,

Normally this type of error encounter while insert or update data on the
table, which is dependable on the other table data.

To avoid such error you should disable foreign keys before insert data and
enable it later.

<http://www.shreeyansh.com;

On Thu, Dec 13, 2018 at 4:50 PM soumitra bhandary <
soumitra.bhandary@hotmail.com> wrote:

> Hello Team ,
>
> I have encountered following issue while restoring the Postgres dump using
> pg_restore . Please provide any suggestion to the same .
>
>    1. This dump was taken using bdr_dump as bdr enabled database and all
>    the BDR configuration and extension was excluded .
>    2. DUMP was taken in a running DB server where BDR was running .
>    3. Postgres Dump was taken in .dump format .
>    4. During restoration of the same using pg_restore getting following
>    error .
>
> Error :
>
> pg_restore: [archiver (db)] Error from TOC entry 3061; 2606 17551 FK
> CONSTRAINT fk_5hrm2vlf9ql5fu043kqepovbr DBNAME
> pg_restore: [archiver (db)] could not execute query: ERROR: insert or
> update on table "user_attribute" violates foreign key constraint
> "fk_5hrm2vlf9ql5fu043kqepovbr"
> DETAIL: Key (user_id)=(1f34ec07-7087-45ff-8a56-f36177752499) is not
> present in table "user_entity".
> Command was: ALTER TABLE ONLY user_attribute
> ADD CONSTRAINT fk_5hrm2vlf9ql5fu043kqepovbr FOREIGN KEY (user_id)
> REFERENCES user_entity...
> pg_restore: [archiver (db)] Error from TOC entry 3065; 2606 17601 FK
> CONSTRAINT fk_c4fqv34p1mbylloxang7b1q3l DBNAME
> pg_restore: [archiver (db)] could not execute query: ERROR: insert or
> update on table "user_role_mapping" violates foreign key constraint
> "fk_c4fqv34p1mbylloxang7b1q3l"
> DETAIL: Key (user_id)=(24d1ee2a-b05e-4c30-a292-84045c47611e) is not
> present in table "user_entity".
>
>
> Thanks ,
>
> Soumitra
>
>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Pg_restore failing due to data inconsistency in dump file
@ 2018-12-13 12:26  soumitra bhandary <soumitra.bhandary@hotmail.com>
  parent: Shreeyansh Dba <shreeyansh2014@gmail.com>
  1 sibling, 2 replies; 7+ messages in thread

From: soumitra bhandary @ 2018-12-13 12:26 UTC (permalink / raw)
  To: Shreeyansh Dba <shreeyansh2014@gmail.com>; +Cc: pgsql-admin

Hi ,

Thanks for the response .

But this one is third party application and dump is restored from dump file not plain text file . So is there any way to control it ?

Thanks,
Soumitra
________________________________
From: Shreeyansh Dba <shreeyansh2014@gmail.com>
Sent: Thursday, December 13, 2018 5:51 PM
To: soumitra.bhandary@hotmail.com
Cc: pgsql-admin
Subject: Re: Pg_restore failing due to data inconsistency in dump file

Hi Soumitra,

Normally this type of error encounter while insert or update data on the table, which is dependable on the other table data.

To avoid such error you should disable foreign keys before insert data and enable it later.

[https://docs.google.com/uc?export=download&id=1gGhoMTYjvHWLCZkro06CHfeV5B0i67aE&revid=0B0kMU...]<http://www.shreeyansh.com;

On Thu, Dec 13, 2018 at 4:50 PM soumitra bhandary <soumitra.bhandary@hotmail.com<mailto:soumitra.bhandary@hotmail.com>> wrote:
Hello Team ,

I have encountered following issue while restoring the Postgres dump using pg_restore . Please provide any suggestion to the same .

  1.  This dump was taken using bdr_dump as bdr enabled database and all the BDR configuration and extension was excluded .
  2.  DUMP was taken in a running DB server where BDR was running .
  3.  Postgres Dump was taken in .dump format .
  4.  During restoration of the same using pg_restore getting following error .

Error :

pg_restore: [archiver (db)] Error from TOC entry 3061; 2606 17551 FK CONSTRAINT fk_5hrm2vlf9ql5fu043kqepovbr DBNAME
pg_restore: [archiver (db)] could not execute query: ERROR: insert or update on table "user_attribute" violates foreign key constraint "fk_5hrm2vlf9ql5fu043kqepovbr"
DETAIL: Key (user_id)=(1f34ec07-7087-45ff-8a56-f36177752499) is not present in table "user_entity".
Command was: ALTER TABLE ONLY user_attribute
ADD CONSTRAINT fk_5hrm2vlf9ql5fu043kqepovbr FOREIGN KEY (user_id) REFERENCES user_entity...
pg_restore: [archiver (db)] Error from TOC entry 3065; 2606 17601 FK CONSTRAINT fk_c4fqv34p1mbylloxang7b1q3l DBNAME
pg_restore: [archiver (db)] could not execute query: ERROR: insert or update on table "user_role_mapping" violates foreign key constraint "fk_c4fqv34p1mbylloxang7b1q3l"
DETAIL: Key (user_id)=(24d1ee2a-b05e-4c30-a292-84045c47611e) is not present in table "user_entity".


Thanks ,

Soumitra

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Pg_restore failing due to data inconsistency in dump file
@ 2018-12-13 12:35  Shreeyansh Dba <shreeyansh2014@gmail.com>
  parent: soumitra bhandary <soumitra.bhandary@hotmail.com>
  1 sibling, 1 reply; 7+ messages in thread

From: Shreeyansh Dba @ 2018-12-13 12:35 UTC (permalink / raw)
  To: soumitra.bhandary@hotmail.com; +Cc: pgsql-admin

You can use --disable-trigger option with pg_restore utility while
performing the restoration.

<http://www.shreeyansh.com;


On Thu, Dec 13, 2018 at 5:56 PM soumitra bhandary <
soumitra.bhandary@hotmail.com> wrote:

> Hi ,
>
> Thanks for the response .
>
> But this one is third party application and dump is restored from dump
> file not plain text file . So is there any way to control it ?
>
> Thanks,
> Soumitra
> ------------------------------
> *From:* Shreeyansh Dba <shreeyansh2014@gmail.com>
> *Sent:* Thursday, December 13, 2018 5:51 PM
> *To:* soumitra.bhandary@hotmail.com
> *Cc:* pgsql-admin
> *Subject:* Re: Pg_restore failing due to data inconsistency in dump file
>
> Hi Soumitra,
>
> Normally this type of error encounter while insert or update data on the
> table, which is dependable on the other table data.
>
> To avoid such error you should disable foreign keys before insert data and
> enable it later.
>
> <http://www.shreeyansh.com;
>
> On Thu, Dec 13, 2018 at 4:50 PM soumitra bhandary <
> soumitra.bhandary@hotmail.com> wrote:
>
> Hello Team ,
>
> I have encountered following issue while restoring the Postgres dump using
> pg_restore . Please provide any suggestion to the same .
>
>    1. This dump was taken using bdr_dump as bdr enabled database and all
>    the BDR configuration and extension was excluded .
>    2. DUMP was taken in a running DB server where BDR was running .
>    3. Postgres Dump was taken in .dump format .
>    4. During restoration of the same using pg_restore getting following
>    error .
>
> Error :
>
> pg_restore: [archiver (db)] Error from TOC entry 3061; 2606 17551 FK
> CONSTRAINT fk_5hrm2vlf9ql5fu043kqepovbr DBNAME
> pg_restore: [archiver (db)] could not execute query: ERROR: insert or
> update on table "user_attribute" violates foreign key constraint
> "fk_5hrm2vlf9ql5fu043kqepovbr"
> DETAIL: Key (user_id)=(1f34ec07-7087-45ff-8a56-f36177752499) is not
> present in table "user_entity".
> Command was: ALTER TABLE ONLY user_attribute
> ADD CONSTRAINT fk_5hrm2vlf9ql5fu043kqepovbr FOREIGN KEY (user_id)
> REFERENCES user_entity...
> pg_restore: [archiver (db)] Error from TOC entry 3065; 2606 17601 FK
> CONSTRAINT fk_c4fqv34p1mbylloxang7b1q3l DBNAME
> pg_restore: [archiver (db)] could not execute query: ERROR: insert or
> update on table "user_role_mapping" violates foreign key constraint
> "fk_c4fqv34p1mbylloxang7b1q3l"
> DETAIL: Key (user_id)=(24d1ee2a-b05e-4c30-a292-84045c47611e) is not
> present in table "user_entity".
>
>
> Thanks ,
>
> Soumitra
>
>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Pg_restore failing due to data inconsistency in dump file
@ 2018-12-13 14:27  Ron <ronljohnsonjr@gmail.com>
  parent: Shreeyansh Dba <shreeyansh2014@gmail.com>
  1 sibling, 0 replies; 7+ messages in thread

From: Ron @ 2018-12-13 14:27 UTC (permalink / raw)
  To: pgsql-admin@lists.postgresql.org

No.  That is *not* the first thing to do.

OP needs to find out how the corruption got into the source in the first 
place.   There's probably corruption in one of the indexes in 
user_role_mapping anduser_entity which support fk_5hrm2vlf9ql5fu043kqepovbr.


On 12/13/2018 06:21 AM, Shreeyansh Dba wrote:
> Hi Soumitra,
>
> Normally this type of error encounter while insert or update data on the 
> table, which is dependable on the other table data.
>
> To avoid such error you should disable foreign keys before insert data and 
> enable it later.
>
> <http://www.shreeyansh.com;
>
> On Thu, Dec 13, 2018 at 4:50 PM soumitra bhandary 
> <soumitra.bhandary@hotmail.com <mailto:soumitra.bhandary@hotmail.com>> wrote:
>
>     Hello Team ,
>
>     I have encountered following issue while restoring the Postgres dump
>     using pg_restore . Please provide any suggestion to the same .
>
>      1. This dump was taken using bdr_dump as bdr enabled database and all
>         the BDR configuration and extension was excluded .
>      2. DUMP was taken in a running DB server where BDR was running .
>      3. Postgres Dump was taken in .dump format .
>      4. During restoration of the same using pg_restore getting following
>         error .
>
>     Error :
>
>     pg_restore:[archiver (db)]Error from TOC entry 3061; 2606 17551 FK
>     CONSTRAINT fk_5hrm2vlf9ql5fu043kqepovbr DBNAME
>     pg_restore:[archiver (db)]could not execute query: ERROR: insert or
>     update on table "user_attribute" violates foreign key constraint
>     "fk_5hrm2vlf9ql5fu043kqepovbr"
>     DETAIL: Key (user_id)=(1f34ec07-7087-45ff-8a56-f36177752499) is not
>     present in table "user_entity".
>     Command was: ALTER TABLE ONLY user_attribute
>     ADD CONSTRAINT fk_5hrm2vlf9ql5fu043kqepovbr FOREIGN KEY (user_id)
>     REFERENCES user_entity...
>     pg_restore:[archiver (db)]Error from TOC entry 3065; 2606 17601 FK
>     CONSTRAINT fk_c4fqv34p1mbylloxang7b1q3l DBNAME
>     pg_restore:[archiver (db)]could not execute query: ERROR: insert or
>     update on table "user_role_mapping" violates foreign key constraint
>     "fk_c4fqv34p1mbylloxang7b1q3l"
>     DETAIL: Key (user_id)=(24d1ee2a-b05e-4c30-a292-84045c47611e) is not
>     present in table "user_entity".
>
>
>     Thanks ,
>
>     Soumitra
>
>

-- 
Angular momentum makes the world go 'round.

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Pg_restore failing due to data inconsistency in dump file
@ 2018-12-13 14:57  soumitra bhandary <soumitra.bhandary@hotmail.com>
  parent: Shreeyansh Dba <shreeyansh2014@gmail.com>
  0 siblings, 0 replies; 7+ messages in thread

From: soumitra bhandary @ 2018-12-13 14:57 UTC (permalink / raw)
  To: Shreeyansh Dba <shreeyansh2014@gmail.com>; +Cc: pgsql-admin

Hi

Tried with that still it is failing and restore process is getting aborted.

Thanks
Soumitra

Sent from my iPhone

On 13-Dec-2018, at 6:07 PM, Shreeyansh Dba <shreeyansh2014@gmail.com<mailto:shreeyansh2014@gmail.com>> wrote:

You can use --disable-trigger option with pg_restore utility while performing the restoration.

[https://docs.google.com/uc?export=download&id=1gGhoMTYjvHWLCZkro06CHfeV5B0i67aE&revid=0B0kMU...]<http://www.shreeyansh.com;


On Thu, Dec 13, 2018 at 5:56 PM soumitra bhandary <soumitra.bhandary@hotmail.com<mailto:soumitra.bhandary@hotmail.com>> wrote:
Hi ,

Thanks for the response .

But this one is third party application and dump is restored from dump file not plain text file . So is there any way to control it ?

Thanks,
Soumitra
________________________________
From: Shreeyansh Dba <shreeyansh2014@gmail.com<mailto:shreeyansh2014@gmail.com>>
Sent: Thursday, December 13, 2018 5:51 PM
To: soumitra.bhandary@hotmail.com<mailto:soumitra.bhandary@hotmail.com>
Cc: pgsql-admin
Subject: Re: Pg_restore failing due to data inconsistency in dump file

Hi Soumitra,

Normally this type of error encounter while insert or update data on the table, which is dependable on the other table data.

To avoid such error you should disable foreign keys before insert data and enable it later.

[https://docs.google.com/uc?export=download&id=1gGhoMTYjvHWLCZkro06CHfeV5B0i67aE&revid=0B0kMU...]<http://www.shreeyansh.com;

On Thu, Dec 13, 2018 at 4:50 PM soumitra bhandary <soumitra.bhandary@hotmail.com<mailto:soumitra.bhandary@hotmail.com>> wrote:
Hello Team ,

I have encountered following issue while restoring the Postgres dump using pg_restore . Please provide any suggestion to the same .

  1.  This dump was taken using bdr_dump as bdr enabled database and all the BDR configuration and extension was excluded .
  2.  DUMP was taken in a running DB server where BDR was running .
  3.  Postgres Dump was taken in .dump format .
  4.  During restoration of the same using pg_restore getting following error .

Error :

pg_restore: [archiver (db)] Error from TOC entry 3061; 2606 17551 FK CONSTRAINT fk_5hrm2vlf9ql5fu043kqepovbr DBNAME
pg_restore: [archiver (db)] could not execute query: ERROR: insert or update on table "user_attribute" violates foreign key constraint "fk_5hrm2vlf9ql5fu043kqepovbr"
DETAIL: Key (user_id)=(1f34ec07-7087-45ff-8a56-f36177752499) is not present in table "user_entity".
Command was: ALTER TABLE ONLY user_attribute
ADD CONSTRAINT fk_5hrm2vlf9ql5fu043kqepovbr FOREIGN KEY (user_id) REFERENCES user_entity...
pg_restore: [archiver (db)] Error from TOC entry 3065; 2606 17601 FK CONSTRAINT fk_c4fqv34p1mbylloxang7b1q3l DBNAME
pg_restore: [archiver (db)] could not execute query: ERROR: insert or update on table "user_role_mapping" violates foreign key constraint "fk_c4fqv34p1mbylloxang7b1q3l"
DETAIL: Key (user_id)=(24d1ee2a-b05e-4c30-a292-84045c47611e) is not present in table "user_entity".


Thanks ,

Soumitra



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Pg_restore failing due to data inconsistency in dump file
@ 2018-12-13 15:25  David G. Johnston <david.g.johnston@gmail.com>
  parent: soumitra bhandary <soumitra.bhandary@hotmail.com>
  1 sibling, 0 replies; 7+ messages in thread

From: David G. Johnston @ 2018-12-13 15:25 UTC (permalink / raw)
  To: soumitra.bhandary@hotmail.com; +Cc: Shreeyansh Dba <shreeyansh2014@gmail.com>; pgsql-admin

On Thu, Dec 13, 2018 at 7:26 AM soumitra bhandary <
soumitra.bhandary@hotmail.com> wrote:

> But this one is third party application and dump is restored from dump
> file not plain text file . So is there any way to control it ?
>

Your backup file (and the source database is comes from) is corrupted.

You need to decide whether you want to restore that backup anyway; or just
throw it away, fix the source database, and generate a new backup file.

If you want to do the former you will want to restore schema only.  Modify
the schema by dropping the foreign key.  Restore the data.  Fix the newly
restored data.  Recreate the foreign key.

David J.

^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2018-12-13 15:25 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-12-13 11:20 Pg_restore failing due to data inconsistency in dump file soumitra bhandary <soumitra.bhandary@hotmail.com>
2018-12-13 12:21 ` Shreeyansh Dba <shreeyansh2014@gmail.com>
2018-12-13 12:26   ` soumitra bhandary <soumitra.bhandary@hotmail.com>
2018-12-13 12:35     ` Shreeyansh Dba <shreeyansh2014@gmail.com>
2018-12-13 14:57       ` soumitra bhandary <soumitra.bhandary@hotmail.com>
2018-12-13 15:25     ` David G. Johnston <david.g.johnston@gmail.com>
2018-12-13 14:27   ` Ron <ronljohnsonjr@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox