update or delete on table "item" violates foreign key constraint "coll2item_item_fk" on table

2,547 views
Skip to first unread message

Marcelo Caceres

unread,
Sep 11, 2018, 10:26:45 AM9/11/18
to DSpace Community
When delete a collection to load data again generates

The batch import you initiated from the DSpace UI was not completed, due to the following reason:
 org.postgresql.util.PSQLException: ERROR: update or delete on table "item" violates foreign key constraint "coll2item_item_fk" on table "collection2item"
  Detail: Key (item_id)=(2) is still referenced from table "collection2item".
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334)
        at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
        at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
        at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
        at org.dspace.storage.rdbms.DatabaseManager.updateQuery(DatabaseManager.java:441)
        at org.dspace.storage.rdbms.DatabaseManager.deleteByValue(DatabaseManager.java:612)
        at org.dspace.storage.rdbms.DatabaseManager.delete(DatabaseManager.java:571)
        at org.dspace.storage.rdbms.DatabaseManager.delete(DatabaseManager.java:796)
        at org.dspace.content.Item.delete(Item.java:1308)
        at org.dspace.content.WorkspaceItem.deleteAll(WorkspaceItem.java:594)
        at org.dspace.app.itemimport.ItemImport.addItem(ItemImport.java:918)
        at org.dspace.app.itemimport.ItemImport.addItems(ItemImport.java:736)
        at org.dspace.app.itemimport.ItemImport$3.run(ItemImport.java:2253)

Configuration used is
DSpace 5.2
postgresql-9.3.6-2-linux-x64
apache-tomcat-7.0.50
apache-maven-3.0.5
apache-ant-1.9.3

All the solutions writed are about migrations from version 1.6 or 1.7.

Someone tell me about a solution in DSpace 5?

Marcelo Caceres

unread,
Sep 11, 2018, 10:44:52 AM9/11/18
to DSpace Community
We can't reproduce this error in a testing server.

Tim Donohue

unread,
Sep 12, 2018, 10:02:45 AM9/12/18
to Marcelo Caceres, DSpace Community
Hi Marcelo,

I'm not sure I understand completely how this error occurred.  However, the error is noting that there's an issue with the *data* within that database (so I'm not surprised that it doesn't occur on another database).

The error is essentially saying that the Item with item_id=2 cannot be deleted because it is still "linked" with a Collection (in the collection2item table).  Maybe this item is "mapped" or "linked" to multiple collections?  You also could lookup the item with that ID and see if you can delete it directly (I'm not sure whether you are using the XMLUI or JSPUI, but both provide administrative options to lookup an Item by its internal ID).

Not sure if this will be of help.  But, if you require more support, feel free to respond on this mailing list so that we can better understand the issue.

Tim

--
All messages to this mailing list should adhere to the DuraSpace Code of Conduct: https://duraspace.org/about/policies/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "DSpace Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-communi...@googlegroups.com.
To post to this group, send email to dspace-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/dspace-community.
For more options, visit https://groups.google.com/d/optout.
--
Tim Donohue
Technical Lead for DSpace & DSpaceDirect
DuraSpace.org | DSpace.org | DSpaceDirect.org

Marcelo Caceres

unread,
Sep 14, 2018, 4:37:57 PM9/14/18
to DSpace Community
The user who loaded the data (Import Batch file) identified inconsistency in the data. Therefore he eliminated a lot. Later it would try to load the same zip (batch) but the reported error occurs and cannot load more data.


El martes, 11 de septiembre de 2018, 10:26:45 (UTC-4), Marcelo Caceres escribió:

Kimberly Chapman

unread,
Sep 17, 2018, 9:04:11 PM9/17/18
to tdon...@duraspace.org, renemarce...@gmail.com, DSpace Community
Hi Tim and Marcelo,

For what it's worth, I have experienced similar errors from time-to-time when trying to delete either items or collections.

See this screenshot, which was an attempt to delete a collection from our sandbox environment. https://drive.google.com/file/d/1wLCqUnVy3EpJLVksK_RzS6Le6FJiVD10/view?usp=sharing

Note that I've experienced these errors since the completion of an April 2018 upgrade from DSpace 3.X JSPUI to DSpace 5.X XMLUI. 

(We use Atmire's hosted Open Repository services, so when I run into these issues I submit a ticket to Atmire, if the error prevents me from doing something that I need to do, and then they resolve the issue.)

I'm not a technical developer, so I don't know if these issues are similar - but I wanted to chime in since I've seen a similar-looking error in our repository. Note that this error, at least for me, occurred with a single collection or single item that is not mapped into multiple collections.

Sincerely,

Kimberly at the University of Arizona Libraries

 

Marcelo Caceres

unread,
Oct 9, 2018, 5:26:42 PM10/9/18
to DSpace Community
Because a solution could not be found, it was decided to recompile Dspace and create the database again.
Possibly the module deleteBatchUpload (ItemImportServiceImpl.java) could not complete the task.

Thank you all for your interest.

El martes, 11 de septiembre de 2018, 10:26:45 (UTC-4), Marcelo Caceres escribió:
Reply all
Reply to author
Forward
0 new messages