geonetwork / geonetwork/core-geonetwork

Unable to create a metadata record using template

Open
#8,310 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
521
Forks
514
Avg merge
6d 13h
Merged PRs (30d)
19

Description

**Describe the bug**
```
Create metadata error
could not execute batch; SQL [insert into Metadata (data, changeDate, createDate, displayorder, doctype, extra, popularity, rating, root, schemaId, title, isTemplate, isHarvested, harvestUri, harvestUuid, groupOwner, owner, source, uuid, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute batch
```

**To Reproduce**
Steps to reproduce the behavior:
1. Go to Contribute -> Add new record
2. Click on 'Dataset' and 'Template for Vector data in ISO19139 (preferred!)'
3. Click on any group for the 'In ..' option.
4. See error in the top-left

**Expected behavior**
Before we were able to create new records, so something must have changed

In detail, from the browser, this is the request URL:
`http://geonetwork-tmc-prod.thinkwhere-labs.com:8080/geonetwork/srv/api/records/duplicate?metadataType=METADATA&sourceUuid=2010&isChildOfSource=false&group=2&isVisibleByAllGroupMembers=false&targetUuid=&hasCategoryOfSource=true`
(this is url is not public)

And the response is:
```
{
"message": "InvalidDataAccessResourceUsageException",
"code": "runtime_exception",
"description": "could not execute batch; SQL [insert into Metadata (data, changeDate, createDate, displayorder, doctype, extra, popularity, rating, root, schemaId, title, isTemplate, isHarvested, harvestUri, harvestUuid, groupOwner, owner, source, uuid, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute batch"
}
```

We are using VERSION geonetwork:3.12.8-postgres, running in Docker.

As other posts suggest, we have checked the hibernate_sequence in the database, and the count of records in the 'metadata' TABLE.

hibernate_sequence:
Current value: 5734
Increment: 1
Start: 100
Minimum: 1
Maximum: 9223372036854775807
Cache: 1

The last ID in the metadata table was 4250

Every time we tried adding a new record to the table, the above sequence was adding 1 (5734, 5735, 5736, ..) which proves the sequence works?

WHAT WE HAVE TRIED SO FAR:

- Rebuild the index using the GUI.
- Restarting the docker container
- Updating the Start sequence (e.g., 100) to be higher than the current value (e.g., 5741)

Lack of more ideas.

Thanks in advance,

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure through the records/duplicate API endpoint using GeoNetwork 3.12.8-postgres in Docker, then inspect the reported SQLGrammarException and the metadata insert operation. Done means identifying why template creation fails, confirming the fix by creating a metadata template, and documenting any required database changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java, postgresql
Domain
api, backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.