Jenkins upgrade failed from 2.263.4 to 2.289.3

I’m trying to upgrade my Jenkins instance from 2.263.4 to 2.289.3.but i failed to upgrade and ended up with the below error. Can anyone help on this please.

EVERE: An attempt to save Jenkins'' global configuration before it has been loaded has been made during milestone Configuration for all jobs updated.  This is indicative of a bug in the caller and may lead tofull or partial loss of configuration.
java.lang.IllegalStateException: call trace
        at jenkins.model.Jenkins.save(Jenkins.java:3377)
        at jenkins.model.Jenkins.saveQuietly(Jenkins.java:3405)
        at jenkins.model.Jenkins.setSecurityRealm(Jenkins.java:2643)
        at jenkins.model.Jenkins$15.run(Jenkins.java:3349)
        at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1129)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:750)
Feb 01, 2022 2:29:00 AM jenkins.InitReactorRunner$1 onTaskFailed
SEVERE: Failed Finalizing set up
java.lang.IllegalStateException: An attempt to save the global configuration was made before it was loaded
        at jenkins.model.Jenkins.save(Jenkins.java:3386)
        at jenkins.model.Jenkins.saveQuietly(Jenkins.java:3405)        at jenkins.model.Jenkins.setSecurityRealm(Jenkins.java:2643)
        at jenkins.model.Jenkins$15.run(Jenkins.java:3349)        at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1129)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:750)

Maybe unrelated: why do you want to upgrade from an old version to an old version? Maybe your error is already fixed in latest LTS 2.319.2.

Thanks Ulli. Due to certain issues, we decided to go ahead with 2.289 at the moment. later we can upgrade to the latest version. Do you have an idea about this error?

No, but a search in the internet revealed: How to fix Jenkins java.lang.IllegalStateException: An attempt to save the global configuration was made before it was loaded - Stack Overflow

I distinctly recall something about this but can’t put my finger on it. I’m sure there was a fix issued but not clear on the circumstances or release.

Not sure if any of these items helps pinpoint:
JENKINS-51856 - Job loading and JCasC conflicts: Introduce new Milestone between EXTENSIONS_AUGMENTED and JOBS_LOADED
and related Google Dev thread - Proposal: new initialization milestone for configuration-as-code-plugin
JCasC PR #1204 - #280 workaround - Add a configurable delay to avoid race condition in initializer
JCasC Issue #1531 - Jenkins not starting after upgrading to 2.266
JENKINS-64295 - An attempt to save the global configuration was made before it was loaded

Hope it helps.

I was able to fix this issue by removing config.xml in the Jenkins home directory. When it is restarted Jenkins upgraded to 2.289 with a new config.xml. But I lost all role-based strategy configurations. However, I can add them manually. :smile:

I can add them manually.

I would recommend to use JCasC for such things. Otherwise you need to add again in 2.303.3, 2.319.3, etc.

I hope you just removed the RoleBasedAuthorizationStrategy section and not the entire config.xml! In any case, it seems like there is a compatibility issue. You are also using JCasC already, correct ?

Where there any warnings or errors logged prior to the Unable to save message?

You are also using JCasC already, correct ? Did you try inserting the delay as some io.jenkins.plugins.casc.ConfigurationAsCode.initialDelay

Prior guidance has been update all the plugins to latest compatible, update core, update plugins. Repeat as necessary if cycling through many LTS major releases.

What is the version of the plugins (RBAC, JCasC, etc.) you are using? Is it the latest compatible w/your core version? Is it the latest version of the plugin overall?