org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2$IDStoreMigrationException: Failure whilst migrating ... #1

Jenkins JIRA | Jesse Glick | 1 year ago
  1. 0

    I ran 1.609.3 with Workflow 1.10 and some other plugin updates on an existing {{$JENKINS_HOME}} with a job containing {code:xml} <org.jenkinsci.plugins.uniqueid.impl.JobIdStore_-JobIdProperty plugin="unique-id@1.2"> <id> <id>...</id> </id> </org.jenkinsci.plugins.uniqueid.impl.JobIdStore_-JobIdProperty> {code} and builds with {{unique-id.txt}} and {code:xml} <org.jenkinsci.plugins.uniqueid.impl.Id plugin="unique-id@1.2"> <id>...</id> </org.jenkinsci.plugins.uniqueid.impl.Id> {code} and got {code:none} ... hudson.model.Run onLoad WARNING: failed to load org.jenkinsci.plugins.uniqueid.impl.Id@... from /.../jobs/.../builds/1/build.xml org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2$IDStoreMigrationException: Failure whilst migrating ... #1 at org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2.migrate(IdStoreMigratorV1ToV2.java:100) at org.jenkinsci.plugins.uniqueid.impl.Id.onLoad(Id.java:78) at hudson.model.Run.onLoad(Run.java:349) at org.jenkinsci.plugins.workflow.job.WorkflowRun.onLoad(WorkflowRun.java:373) at hudson.model.RunMap.retrieve(RunMap.java:223) at ... at jenkins.model.lazy.LazyLoadRunMapEntrySet$1.next(LazyLoadRunMapEntrySet.java:63) at java.util.AbstractMap$2$1.next(AbstractMap.java:396) at org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2$RunIDMigrationThread.run(IdStoreMigratorV1ToV2.java:137) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.workflow.job.WorkflowRun#execution for class org.jenkinsci.plugins.workflow.job.WorkflowRun at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:214) at ... at com.thoughtworks.xstream.XStream.toXML(XStream.java:988) at hudson.XmlFile.write(XmlFile.java:178) at hudson.model.Run.save(Run.java:1898) at org.jenkinsci.plugins.uniqueid.impl.RunIdStore.remove(RunIdStore.java:33) at org.jenkinsci.plugins.uniqueid.impl.RunIdStore.remove(RunIdStore.java:18) at org.jenkinsci.plugins.uniqueid.impl.LegacyIdStore.removeId(LegacyIdStore.java:83) at org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2.migrate(IdStoreMigratorV1ToV2.java:90) ... 14 more Caused by: java.lang.NullPointerException at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$ConverterImpl.marshal(CpsFlowExecution.java:835) at hudson.util.XStream2$AssociatedConverterImpl.marshal(XStream2.java:358) at ... {code} What seems to be happening: {{CpsFlowExecution.heads}} is null. Normally this is set either when creating a new build, or when restoring a build in {{initializeStorage}}, called from {{onLoad}}, called in turn from {{WorkflowRun.onLoad}}. However that first calls {{super.onLoad}}, which calls {{onLoad}} of each {{RunAction2}}, including {{Id}}. Fine, except _that_ in turn does some stuff which ultimately calls {{Run.save}}, *before* {{Run.onLoad}} has even completed! So the {{WorkflowRun}} is being asked to save its state before it has finished initializing its own state. Could perhaps be worked around in Workflow, but this feels to me like a design problem in {{unique-id}}: it should not be asking to save a {{Run}} until that build has been fully loaded. This seems like a straightforward fix to make: just have {{RunIDMigrationThread}} collect a list of builds that ought to be saved, and do the saving after the loading, rather than from inside {{RunIdStore.remove}}. Might be able to use {{BulkChange}} here; not sure.

    Jenkins JIRA | 1 year ago | Jesse Glick
    org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2$IDStoreMigrationException: Failure whilst migrating ... #1
  2. 0

    I ran 1.609.3 with Workflow 1.10 and some other plugin updates on an existing {{$JENKINS_HOME}} with a job containing {code:xml} <org.jenkinsci.plugins.uniqueid.impl.JobIdStore_-JobIdProperty plugin="unique-id@1.2"> <id> <id>...</id> </id> </org.jenkinsci.plugins.uniqueid.impl.JobIdStore_-JobIdProperty> {code} and builds with {{unique-id.txt}} and {code:xml} <org.jenkinsci.plugins.uniqueid.impl.Id plugin="unique-id@1.2"> <id>...</id> </org.jenkinsci.plugins.uniqueid.impl.Id> {code} and got {code:none} ... hudson.model.Run onLoad WARNING: failed to load org.jenkinsci.plugins.uniqueid.impl.Id@... from /.../jobs/.../builds/1/build.xml org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2$IDStoreMigrationException: Failure whilst migrating ... #1 at org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2.migrate(IdStoreMigratorV1ToV2.java:100) at org.jenkinsci.plugins.uniqueid.impl.Id.onLoad(Id.java:78) at hudson.model.Run.onLoad(Run.java:349) at org.jenkinsci.plugins.workflow.job.WorkflowRun.onLoad(WorkflowRun.java:373) at hudson.model.RunMap.retrieve(RunMap.java:223) at ... at jenkins.model.lazy.LazyLoadRunMapEntrySet$1.next(LazyLoadRunMapEntrySet.java:63) at java.util.AbstractMap$2$1.next(AbstractMap.java:396) at org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2$RunIDMigrationThread.run(IdStoreMigratorV1ToV2.java:137) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.workflow.job.WorkflowRun#execution for class org.jenkinsci.plugins.workflow.job.WorkflowRun at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:214) at ... at com.thoughtworks.xstream.XStream.toXML(XStream.java:988) at hudson.XmlFile.write(XmlFile.java:178) at hudson.model.Run.save(Run.java:1898) at org.jenkinsci.plugins.uniqueid.impl.RunIdStore.remove(RunIdStore.java:33) at org.jenkinsci.plugins.uniqueid.impl.RunIdStore.remove(RunIdStore.java:18) at org.jenkinsci.plugins.uniqueid.impl.LegacyIdStore.removeId(LegacyIdStore.java:83) at org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2.migrate(IdStoreMigratorV1ToV2.java:90) ... 14 more Caused by: java.lang.NullPointerException at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$ConverterImpl.marshal(CpsFlowExecution.java:835) at hudson.util.XStream2$AssociatedConverterImpl.marshal(XStream2.java:358) at ... {code} What seems to be happening: {{CpsFlowExecution.heads}} is null. Normally this is set either when creating a new build, or when restoring a build in {{initializeStorage}}, called from {{onLoad}}, called in turn from {{WorkflowRun.onLoad}}. However that first calls {{super.onLoad}}, which calls {{onLoad}} of each {{RunAction2}}, including {{Id}}. Fine, except _that_ in turn does some stuff which ultimately calls {{Run.save}}, *before* {{Run.onLoad}} has even completed! So the {{WorkflowRun}} is being asked to save its state before it has finished initializing its own state. Could perhaps be worked around in Workflow, but this feels to me like a design problem in {{unique-id}}: it should not be asking to save a {{Run}} until that build has been fully loaded. This seems like a straightforward fix to make: just have {{RunIDMigrationThread}} collect a list of builds that ought to be saved, and do the saving after the loading, rather than from inside {{RunIdStore.remove}}. Might be able to use {{BulkChange}} here; not sure.

    Jenkins JIRA | 1 year ago | Jesse Glick
    org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2$IDStoreMigrationException: Failure whilst migrating ... #1

    Root Cause Analysis

    1. org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2$IDStoreMigrationException

      Failure whilst migrating ... #1

      at org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2.migrate()
    2. org.jenkinsci.plugins
      Id.onLoad
      1. org.jenkinsci.plugins.uniqueid.impl.IdStoreMigratorV1ToV2.migrate(IdStoreMigratorV1ToV2.java:100)
      2. org.jenkinsci.plugins.uniqueid.impl.Id.onLoad(Id.java:78)
      2 frames
    3. Hudson
      Run.onLoad
      1. hudson.model.Run.onLoad(Run.java:349)
      1 frame
    4. org.jenkinsci.plugins
      WorkflowRun.onLoad
      1. org.jenkinsci.plugins.workflow.job.WorkflowRun.onLoad(WorkflowRun.java:373)
      1 frame
    5. Hudson
      RunMap.retrieve
      1. hudson.model.RunMap.retrieve(RunMap.java:223)
      1 frame