Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-23180

Prevent duplicate label by adding a constraint in the CONTENT_LABEL table

    XMLWordPrintable

Details

    Description

      It's possible to create a duplicate label in Confluence. This prevents operation such as:

      • editing a page (results in a stack trace)
      • deleting a space
      org.springframework.dao.InvalidDataAccessApiUsageException: deleted object would be re-saved by cascade (remove deleted object from associations): 1836138, of class: com.atlassian.confluence.labels.Labelling; nested exception is net.sf.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): 1836138, of class: com.atlassian.confluence.labels.Labelling
      Caused by: net.sf.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): 1836138, of class: com.atlassian.confluence.labels.Labelling
      	at net.sf.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:761)
      	at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:739)
      	at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1384)
      	at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
      	at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
      	at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:526)
      	at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:452)
      	at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
      	at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:482)
      	at net.sf.hibernate.impl.SessionImpl.preFlushEntities(SessionImpl.java:2699)
      	at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2269)
      	at net.sf.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1813)
      

      It's not clear which operation can cause the duplicate, the current suspicion is this was due to an xml import or certain plugin operations can cause this.

      CREATE
          TABLE content_label
          (
              id BIGINT NOT NULL,
              labelid BIGINT NOT NULL,
              contentid BIGINT NOT NULL,
              owner CHARACTER VARYING(255),
              creationdate TIMESTAMP(6) WITHOUT TIME ZONE,
              lastmoddate TIMESTAMP(6) WITHOUT TIME ZONE,
              PRIMARY KEY (id),
              CONSTRAINT fkf0e7436e27072aef FOREIGN KEY (labelid) REFERENCES label (labelid),
              CONSTRAINT fkf0e7436e8dd41734 FOREIGN KEY (contentid) REFERENCES content (contentid)
          )
      

      As can be seen from the DDL, the CONTENT_LABEL table currently owns two contraints in contentid and labelid columns, but perhaps we should make them into a combined constraint. So both the labelid and contentid must be unique for each row.

      Current work around involves deleting the row where the duplicate was noticed. A duplicate means two labels of the same labelid exist on the same content (contentid).

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rhartono Roy Hartono [Atlassian]
              Votes:
              7 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated: