Hi there,

You should be able to get past this by updating the primary_bitstream_id field 
to Null for those records that refer to deleted bitstreams.  For postgresql, try

Update bundle set primary_bitstream_id = 'NULL' where bundle_id in (select 
bundle_id from bundle, bitstream where deleted = '1' and primary_bitstream_id = 
bitstream_id)

That should be close, anyway.

B--

From: Michael White [mailto:michael.wh...@stir.ac.uk]
Sent: Wednesday, March 13, 2013 9:08 AM
To: Hilton Gibson (hilton.gib...@gmail.com); dspace-tech@lists.sourceforge.net
Subject: Re: [Dspace-tech] DSpace cleanup error

Hi,

> I get this error when doing a cleanup with "-v".
> "Error: ERROR: update or delete on table "bitstream" violates foreign key 
> constraint "bundle_primary_bitstream_id_fkey" on table "bundle"
>   Detail: Key (bitstream_id)=(67984) is still referenced from table "bundle".

> Is there a query that can fix this and is this a bug?

I've also been plagued by this error today (slightly different text, but using 
v1.6.2 not v1.8.2?) whilst experimenting with "cleanup" on my DEV system (which 
is an old and probably slightly mangled copy of our PROD system). I've now 
completed the assetstore cleanup of our DEV system, but I'm building up to 
doing it on our PROD system (which has 3 times as many records) so I would also 
be interested if there is a nice bit of SQL that can find the problem records 
and sort them out in one go :).

The first few times I got this error, I checked our "bundle2bitstream" table, 
but there was no reference to the bitstreams in question, so I wasn't sure 
where the (foreign key) reference from the "bundle" table could be coming from 
. . .

Being a bit of philistine, I've just been watching the output from the job with 
one eye, and when it fails with the above error, sorting out the bitstream 
record in question by simply updating the "delete" flag to "FALSE" - i.e. 
forcing the cleanup task to just ignore the bitstream record in question, e.g.:

UPDATE bitstream SET deleted = 'FALSE'
WHERE bitstream_id = 67984

- then kick off the job again. This "manual intervention" is not ideal though, 
as you say, but it has got me past the problem records.

As I said, I have no idea why this error is being generated as I could find no 
references to the problematic bitstreams elsewhere, so it felt like a bug to 
me, but this is our DEV system, and I have done lots of strange things with it 
over the years, so anything is possible!

Regards,

Mike
Michael White
eLearning Liaison and Development (eLD)
Information Services
S8, Library
University of Stirling
Stirling SCOTLAND
FK9 4LA
Email: michael.wh...@stir.ac.uk<mailto:michael.wh...@stir.ac.uk>
Tel: +44 (0) 1786 466877
Fax: +44 (0) 1786 466880
http://www.stir.ac.uk/is/staff/about/teams/aldt/#eld

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

Message: 1
Date: Wed, 13 Mar 2013 12:23:41 +0200
From: Hilton Gibson <hilton.gib...@gmail.com<mailto:hilton.gib...@gmail.com>>
Subject: [Dspace-tech] DSpace cleanup error
To: dspace-tech 
<dspace-tech@lists.sourceforge.net<mailto:dspace-tech@lists.sourceforge.net>>
Message-ID:
        
<caav1wv6de_qybsmakw7wqsufw13hntgwqevyukwbsamhokk...@mail.gmail.com<mailto:caav1wv6de_qybsmakw7wqsufw13hntgwqevyukwbsamhokk...@mail.gmail.com>>
Content-Type: text/plain; charset="utf-8"

Hi All

I get this error when doing a cleanup with "-v".
"Error: ERROR: update or delete on table "bitstream" violates foreign key 
constraint "bundle_primary_bitstream_id_fkey" on table "bundle"
  Detail: Key (bitstream_id)=(67984) is still referenced from table "bundle".

The fault is in the "bundle2bitstream" table.
This table lists the order of the bitstreams, but the bitstream listed as "0" 
does not appear in the "bundle" table as the "bitstream_id".

Is there a query that can fix this and is this a bug?
I think there are many records like this and it would take forever to fix 
manually.

DSpace 1.8.2 and XMLUI.

--
*Hilton Gibson*
Systems Administrator
JS Gericke Library
Room 1025D
Stellenbosch University
Private Bag X5036
Stellenbosch
7599
South Africa

Tel: +27 21 808 4100 | Cell: +27 84 646 4758 http://library.sun.ac.za 
http://scholar.sun.ac.za http://ar1.sun.ac.za http://aj1.sun.ac.za




________________________________
The University of Stirling is ranked in the top 50 in the world in The Times 
Higher Education 100 Under 50 table, which ranks the world's best 100 
universities under 50 years old.
The University of Stirling is a charity registered in Scotland, number SC 
011159.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
DSpace-tech mailing list
DSpace-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-tech
List Etiquette: https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette

Reply via email to