"Integrity constraint violation: 1062 Duplicate entry" on node:repair

Hi, I’m running into issues when doing a node:repair and don’t see a way to fix it. The setup is currently working under Neos 3.1.17 but prevails since 2.3.x. It only affects a certain nodetype that has 2 content collections configured (“main” and “meta”) with the following nodetype configuration:

'Neos.Shop:ShopCategory':
  superTypes:
    'Neos.NodeTypes:Page': TRUE
    childNodes:
    meta:
      type: 'Neos.Neos:ContentCollection'
  constraints:
    nodeTypes:
      '*': FALSE
  ui:
    label: 'Shop Category'
    icon: icon-shopping-cart
    group: shop
    inspector:
      tabs:
        shop:
          label: Shop
          icon: icon-shopping-cart
      groups:
        shop:
          tab: shop
          label: 'Shop options'
  properties:
    mapping:
      type: string
      defaultValue: ''
      ui:
        label: 'Category Mapping'
        inspector:
          group: shop
          position: 10
    filters:
      type: string
      defaultValue: ''
      ui:
        label: 'Category Filters'
        inspector:
          group: shop
          position: 20

The fusion object looks like this:

prototype(Neos.Shop:ShopCategory) {
	templatePath = 'resource://Neos.Shop/Private/Templates/NodeTypes/ShopCategory.html'

	# Render the meta ContentCollection
	meta = Neos.Neos:ContentCollection {
		nodePath = 'meta'
	}
}

Currently, there are a couple hundred nodes of this nodetype in our database, around 300-400 per dimension. We’re only running two dimensions (“de” = base dimension and “fr”). ShopCategory nodes seem to randomly “drop” one of the content collections, so either “main” or “meta”. Both can be affected, sometimes both together are missing, and it can happen in either dimension. However, when looking into the database, the nodes are still there!!

So what happens when running node:repair on the affected database is, it recreates a “missing” content collection and then, throws the following error:

An exception occurred while executing 'INSERT INTO neos_contentrepository_domain_model_nodedata (persistence_object_identifier, pathhash, path, parentpathhash, parentpath, identifier, sortingindex, removed, dimensionshash, lastmodificationdatetime, lastpublicationdatetime, hiddenbeforedatetime, hiddenafterdatetime, dimensionvalues, properties, nodetype, creationdatetime, hidden, hiddeninindex, accessroles, workspace, contentobjectproxy, movedto) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["e568b901-9cfa-4e6d-bfb8-16a581959580", "fc1bdb4367b05b232f41c3a7cae980c1", "\/sites\/site\/shop\/kinder\/node-58a5b66c6f7fe\/node-jyy5lb6ggm99b\/main", "0eb41802ed080b00c719deb6b46f9f9e", "\/sites\/site\/shop\/kinder\/node-58a5b66c6f7fe\/node-jyy5lb6ggm99b", "efc7ec4d-29dd-6ca1-c5cb-a849af280f26", 300, 0, "8f21da181f6ce38197fcb78d49f5384e", "2018-08-28 11:30:43", null, null, null, "{\n    \"language\": {\n        \"0\": \"fr\"\n    }\n}", "{\n    \"class\": \"\",\n    \"margintop\": \"\",\n    \"marginbottom\": \"\",\n    \"alignContent\": \"\"\n}", "Neos.Neos:ContentCollection", "2018-08-28 11:30:43", 0, 0, "{}", "live", null, null]:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
'fc1bdb4367b05b232f41c3a7cae980c1-live-8f21da181f6ce38197fcb78d49' for
key 'UNIQ_CE6515692DBEC7578D94001992F8FB01'

Type: Doctrine\DBAL\Exception\UniqueConstraintViolationException
File: Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
Line: 66

Nested exception:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'fc1bdb4367b05b232f41c3a7cae980c1-live-8f21da181f6ce38197fcb78d49' for key 'UNIQ_CE6515692DBEC7578D94001992F8FB01'

Type: Doctrine\DBAL\Driver\PDOException
Code: 23000
File: Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php
Line: 107

Nested exception:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'fc1bdb4367b05b232f41c3a7cae980c1-live-8f21da181f6ce38197fcb78d49' for key 'UNIQ_CE6515692DBEC7578D94001992F8FB01'

Type: PDOException
Code: 23000
File: Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php
Line: 105

So far I tried to do the following: After calling node:repair and getting the error message, I looked for the affected node in the database and removed all its affected content collections (e.g. all of “main” in dimension “fr”). My hopes were, that all duplicates were removed and that node:repair would just recreate one content collection, which it actually does! However, it will encounter another node with the same issue and so on. It’s quite a hassle… And the newly created content collection will still not render in the backend.

Any hints how I could solve this issue, improve my nodetype config, adjust the database, etc. would be greatly appreciated!

The YAML you postet here was indented wrong, I guess just a copy&paste issue?

What happens if you are explicit:

'Neos.Shop:ShopCategory':
  superTypes:
    'Neos.NodeTypes:Page': TRUE
  childNodes:
    main:
      type: 'Neos.Neos:ContentCollection'
    meta:
      type: 'Neos.Neos:ContentCollection'