With a datadir/db migrated from 3.4, trying to edit an existing metadata blows hard in the logs:
2020-08-28 12:16:17,615 INFO [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] - HHH000010: On release of batch it still contained JDBC statements
2020-08-28 12:16:17,626 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - SQL Error: 0, SQLState: 23503
2020-08-28 12:16:17,642 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - Batch entry 0 insert into public.OperationAllowed (groupId, metadataId, operationId) values (502939, 185363329, 0) was aborted: ERROR: insert or update on table "operationallowed" violates foreign key constraint "operationallowed_metadataid_fkey"
Détail : Key (metadataid)=(185363329) is not present in table "metadata". Call getNextException to see other errors in the batch.
2020-08-28 12:16:17,642 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - SQL Error: 0, SQLState: 23503
2020-08-28 12:16:17,642 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - ERROR: insert or update on table "operationallowed" violates foreign key constraint "operationallowed_metadataid_fkey"
Détail : Key (metadataid)=(185363329) is not present in table "metadata".
2020-08-28 12:16:17,734 ERROR [org.hibernate.engine.jdbc.batch.internal.BatchingBatch] - HHH000315: Exception executing batch [could not execute batch]
2020-08-28 12:16:17,870 ERROR [geonetwork.datamanager] - Editing instance creation failed
org.springframework.dao.DataIntegrityViolationException: could not execute batch; SQL [insert into public.OperationAllowed (groupId, metadataId, operationId) values (?, ?, ?)]; constraint [operationallowed_metadataid_fkey]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute batch
...
2020-08-28 12:25:17,650 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - SQL Error: 0, SQLState: 25P02
2020-08-28 12:25:17,651 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - ERROR: current transaction is aborted, commands ignored until end of transaction block
2020-08-28 12:25:17,653 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - SQL Error: 0, SQLState: 25P02
2020-08-28 12:25:17,653 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - ERROR: current transaction is aborted, commands ignored until end of transaction block
2020-08-28 12:25:17,653 ERROR [geonetwork.datamanager] - Couldn't update the operations of the draft 185363329
org.springframework.orm.jpa.JpaSystemException: could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet
my guess/understanding of this mumbojumbo is that geonetwork expects the existing metadata (with a given metadataid
of 185361253) to be copied first with a new metadataid
(185363329 is the next value for hibernate_sequence
) and then operations are done on this new copy of the MD, but for some reason the MD isnt cloned first. Note that i dont think i have the fancy new workflow features enabled (how to be sure & where to check ?) but all the sql migration scripts between 3.4 and 3.8 seem to have run without issues.
creating a new MD and editing it afterwards seems to work, so it seems its an issue only for MDs created pre-3.8.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><apiError><code>runtime_exception</code><description>could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet</description><message>JpaSystemException</message></apiError>