MID Server startup fails: Persistence directory already locked by another processIssue Your MID Server may fail to start up, perhaps after an upgrade, and this exception is seen in the agent log: MIDServer SEVERE *** ERROR *** Unexpected exception, terminating the MID serverorg.ehcache.StateTransitionException: Persistence directory already locked by another process: C:\<xxx>\agent\work\cacheat org.ehcache.core.StatusTransitioner$Transition.failed(StatusTransitioner.java:235) The following log entries are repeated in the agent log. (a Rome version on Linux example) 06/18/22 03:36:37 (623) WrapperStartStopAppMain Using configuration: /<xxx>/agent/config.xml06/18/22 03:36:37 (979) WrapperStartStopAppMain Logger config: root=INFO06/18/22 03:36:37 (982) WrapperStartStopAppMain Refreshing LoggerFactory cache06/18/22 03:36:38 (046) WrapperStartStopAppMain Welcome to the ServiceNow MID Server06/18/22 03:36:38 (444) WrapperStartStopAppMain Attempting to load boot config file at location: <xxx>/agent/boot-config.yaml06/18/22 03:36:38 (444) WrapperStartStopAppMain Boot configuration file not found at default location: <xxx>/agent/boot-config.yaml, providing empty configuration06/18/22 03:36:38 (474) MIDServer Initializing MID Server06/18/22 03:36:38 (475) MIDServer Running under Java version: 11.0.9.1-sncmid1, java PID: 2907, args: start06/18/22 03:36:38 (602) MIDServer Running in Commercial (non-FIPS Enforced) mode06/18/22 03:36:39 (121) MIDServer Running MID server with the following security providers:06/18/22 03:36:39 (121) MIDServer SUN06/18/22 03:36:39 (121) MIDServer SunRsaSign06/18/22 03:36:39 (121) MIDServer SunEC06/18/22 03:36:39 (121) MIDServer SunJSSE06/18/22 03:36:39 (121) MIDServer SunJCE06/18/22 03:36:39 (121) MIDServer SunJGSS06/18/22 03:36:39 (121) MIDServer SunSASL06/18/22 03:36:39 (121) MIDServer XMLDSig06/18/22 03:36:39 (121) MIDServer SunPCSC06/18/22 03:36:39 (121) MIDServer JdkLDAP06/18/22 03:36:39 (121) MIDServer JdkSASL06/18/22 03:36:39 (122) MIDServer SunPKCS1106/18/22 03:36:39 (122) MIDServer BCFIPS06/18/22 03:36:39 (122) MIDServer BCJSSE06/18/22 03:36:39 (244) MIDServer JVM default socket factory: class com.service_now.mid.security.policy.PolicyBasedSSLSocketFactory06/18/22 03:36:39 (244) MIDServer Creating injector...06/18/22 03:36:39 (251) MIDServer Loaded credentials provider: com.service_now.mid.keypairs.provider.standard.StandardKeyPairsProvider06/18/22 03:36:41 (326) MIDServer Setting basic authentication with user MID_Server_User_106/18/22 03:36:41 (331) MIDServer Using proxy host=localhost, port=3128, user=null06/18/22 03:36:41 (368) MIDServer ThreadPool-Interactive started with corePoolSize: 10, maxPoolSize: 10, maximumQueueSize: 4006/18/22 03:36:41 (371) MIDServer ThreadPool-Expedited started with corePoolSize: 20, maxPoolSize: 20, maximumQueueSize: 40006/18/22 03:36:41 (375) MIDServer ThreadPool-Standard started with corePoolSize: 25, maxPoolSize: 25, maximumQueueSize: 50006/18/22 03:36:41 (388) MIDServer ExtensionContainer ThreadPool started with corePoolSize: 25, maximumPoolSize: 25, maximumQueueSize: 50006/18/22 03:36:41 (593) MIDServer SEVERE *** ERROR *** Unexpected exception, terminating the MID serverorg.ehcache.StateTransitionException: Persistence directory already locked by another process: /servicenow/<xxx>/agent/work/cache at org.ehcache.core.StatusTransitioner$Transition.failed(StatusTransitioner.java:235) at org.ehcache.core.EhcacheManager.init(EhcacheManager.java:603) at org.ehcache.jsr107.EhcacheCachingProvider.createCacheManager(EhcacheCachingProvider.java:155) at org.ehcache.jsr107.EhcacheCachingProvider.getCacheManager(EhcacheCachingProvider.java:131) at org.ehcache.jsr107.EhcacheCachingProvider.getCacheManager(EhcacheCachingProvider.java:94) at com.service_now.mid.cache.Jsr107Module.provideCacheManager(Jsr107Module.java:56) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.google.inject.internal.ProviderMethod$ReflectionProviderMethod.doProvision(ProviderMethod.java:284) at com.google.inject.internal.ProviderMethod.doProvision(ProviderMethod.java:171) at com.google.inject.internal.InternalProviderInstanceBindingImpl$CyclicFactory.provision(InternalProviderInstanceBindingImpl.java:185) at com.google.inject.internal.InternalProviderInstanceBindingImpl$CyclicFactory.get(InternalProviderInstanceBindingImpl.java:162) at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:169) at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45) at com.google.inject.internal.ExposedKeyFactory.get(ExposedKeyFactory.java:57) at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:40) at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:60) at com.google.inject.internal.ProviderMethod.doProvision(ProviderMethod.java:171) at com.google.inject.internal.InternalProviderInstanceBindingImpl$CyclicFactory.provision(InternalProviderInstanceBindingImpl.java:185) at com.google.inject.internal.InternalProviderInstanceBindingImpl$CyclicFactory.get(InternalProviderInstanceBindingImpl.java:162) at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:169) at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45) at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:40) at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:60) at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113) at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91) at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:296) at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:169) at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45) at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:213) at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:186) at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:113) at com.google.inject.Guice.createInjector(Guice.java:87) at com.google.inject.Guice.createInjector(Guice.java:69) at com.google.inject.Guice.createInjector(Guice.java:59) at com.service_now.mid.MIDServer.createInjector(MIDServer.java:385) at com.service_now.mid.MIDServer.run(MIDServer.java:275) at com.service_now.mid.Main.run(Main.java:143) at com.snc.llama.bootstrap.api.Bootstrapper.run(Bootstrapper.java:52) at com.snc.llama.thirdparty.guice.boot.api.GuiceBootstrapper.run(GuiceBootstrapper.java:27) at com.service_now.mid.Main.doStaticStartRequest(Main.java:487) at com.service_now.mid.Main.doStaticCommandDispatch(Main.java:473) at com.service_now.mid.Main.main(Main.java:108) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.tanukisoftware.wrapper.WrapperStartStopApp.run(WrapperStartStopApp.java:429) at java.base/java.lang.Thread.run(Thread.java:834)Caused by: java.lang.RuntimeException: Persistence directory already locked by another process: /<xxx>/agent/work/cache at org.ehcache.impl.persistence.DefaultLocalPersistenceService.internalStart(DefaultLocalPersistenceService.java:105) at org.ehcache.impl.persistence.DefaultLocalPersistenceService.start(DefaultLocalPersistenceService.java:75) at org.ehcache.core.internal.service.ServiceLocator.startAllServices(ServiceLocator.java:126) at org.ehcache.core.EhcacheManager.init(EhcacheManager.java:575) ... 52 more06/18/22 03:36:41 (642) MIDServer the ServiceNow MID Server is now terminated ReleaseThis has been seen in Rome version MID Servers. It may affect others.CauseThe cause is probably related to "FileDBProviderImpl - Failed to clean the DB Cached files during MID startup" errors, that may be related to file/folder permissions.ResolutionStop the MID Server serviceManually delete the .lock file from the agent/work/cache folderCheck the file folder permissions look correct for the agent folder, plus all subfolders and files. Restart the MID Server Service, and it should be back online