I've had a look into this and need help/feedback from probably Chris or Kai with regards to the way configuration is loaded via the ConfigAdmin asynchronous "updated" [ConfigDispatcher > MysqlPersistenceService] method during startup. Its a lazy method by design according to OSGi spec.
Most of the persistence services that rely on a connection being established (MySQL etc) prior to being queryable need their configuration loading from ConfigAdmin first - ConfigAdmin is obviously required for loading server connection details.
OH is wiring the events up for the "restoreOnStartup" during initalize (item) of PersistenceManager which is called once, prior to the config being loaded via the "updated" method.
[addPersistenceService > startEventHandling > initialize (item)] PersistenceManager.
As its not possible to load the config synchronously from ConfigAdmin (according to OSGi specs) then the restoreOnStartup for this particular type of service fails as config is not loaded and thus connection not established and restore fails.
I don't have enough experience or knowledge at this point to resolve - there seems to be a fair few theoretical solutions but none that I can identify that are practical or require minimal changes and cause minimal impact - that's my very slightly informed guess anyway.
My guess (based on zero experience!) -
Don't wire up the events during initalize of PersistenceManager for restoreOnStartup and wait for ConfigAdmin to load prior to doing so (events etc) ??
ConfigAdmin loads before PersistenceManager ??
Something else ??
I don't wish to use other persistence stores like rrd4j, db4o - although good and technically a "better" solution for restoration of states from local file system. I simply don't want to have to manage the additional persist config nor the extra, although marginal, memory overhead with another persistence binding purely for restoration of item states. I'd trust my MySQL service will (mostly) always be available as its locally hosted.
Any help/suggestions would be appreciated!