With the recent spate of miscellaneous delivery delays along with the introduction of the queue_worker management system, we are moving into an arena where we will run into weird problems with synchronization of config variables (PConfig, IConfig, AbConfig, --- basically, any config that is intended to be synchronized).
Maybe someone will tell me I'm wrong, but from what I see, there is a possibility for desynchronization of these variables. Consider the following example with pconfig:
A cloned channel MyChan on 2 different hubs HubA, HubB.
An update to pconfig.configvar happens on HubA, but delivery is deferred for an hour. 20 minutes later, a change to pconfig.configvar happens on HubB, but is immediately delivered to HubA.
There is no way to recall the delivery from HubA's queue. So everything is fine for 40 minutes until HubA delivers the pconfig.configvar update to HubB. Then, HubB will have an old value.
The problem can be mitigated easily enough, but eliminating the problem is much more difficult.
A simple serial counter added to the Config tables the current value of which is sent with each update allows a simple comparison (is the current value in my database newer or older than the one being delivered). But because things are distributed, there is a possiblity that the incoming value will be the same as the current value. Or, depending on the exact circumstances, an incoming value could be lower and still be newer.
A timestamp (maybe even php microtime()) may be the way to go - hopefully we can expect clocks to be synchronized to some reasonable degree. The chances of a manual update at the exact same second are slim, but the possibility of creating some sort of automation that would update the config variables (eg., some sort of "channel bot" - yes, development in process) increases the likelihood.
I'm just an Olde Tyme hacker and weekend (and evening and every spare second lately) coder. So I just pick new stuff up as I go. Those of you who know better... what are the best ways to handle this?
!!
Hubzilla Development