Recursive Blueprints

by DaveMcW

Automate blueprints to build a self-expanding factory.

Content
1 year, 6 days ago
0.13 - 1.1
27.0K
Blueprints

b Desync Risk

5 years ago
(updated 5 years ago)

Hi,

We suffered some regular player desyncs and Klonan identified differences in the script.dat between the mp save and the desync save for both Recursive Blueprints and Train Supply Manager's mod data.
to fix it temporarily we restart the server and its ok for hours again before going bad.
The full desync file can be found here: https://www.dropbox.com/s/aeudthhyrv1q5l9/desync-report-2018-12-09_19-59-40.zip?dl=0

using version 0.16.4 of the mod with 0.16.51 of factorio

5 years ago
(updated 5 years ago)

None of the data under the mod's control is different.

All the deployer chests do have different memory addresses. I have no idea what could cause that, or if it's even a problem.

5 years ago
(updated 5 years ago)

Klonan (the factorio developer) highlighted it as unexpected and possibly related to our MP desynchronization issues in the Factorio Mod Making discord. Some of the other mods entity references in the file are the same on both the server and client script.dat files.

5 years ago

The issues take many hours (10+) To materialise on the MP server and are fixed by a server restart until they occur again.
I can only pass on his comments.

5 years ago

If Klonan can provide a patch or even an example of bad mode code I will be happy to fix it.

5 years ago
(updated 5 years ago)

I've had a look through the code and the below section looks odd to me.
1: net_cache is a global lua variable, but not a global mod variable. It appears to be used as a lookup table, but isn't being stored in the mods state.
2: There is a global lua variable called "last_update" which seems to be called, but never set. Is this meant to be the same as the later usage of "ent_cache.last_update" in the function?

-- Cache the circuit networks to speed up performance
function update_net_cache(ent)
  if not net_cache then
    net_cache = {}
  end

  local ent_cache = net_cache[ent.unit_number]
  if not ent_cache then
    ent_cache = {last_update=-1}
    net_cache[ent.unit_number] = ent_cache
  end

  -- Get the circuit networks at most once per tick per entity
  if game.tick > ent_cache.last_update then

    if not ent_cache.red_network or not ent_cache.red_network.valid then
      ent_cache.red_network = ent.get_circuit_network(defines.wire_type.red)
    end

    if not ent_cache.green_network or not ent_cache.green_network.valid then
      ent_cache.green_network = ent.get_circuit_network(defines.wire_type.green)
    end

    ent_cache.last_update = game.tick
  end
  return ent_cache;
end
5 years ago
(updated 5 years ago)

1: All data pulled from net_cache is refreshed every tick, so in theory it should never desync. But I guess it is plausible that obsolete entries in the table could cause a desync in the Lua garbage collector resulting in desynced memory addresses.
2: Yes, this is simply a way to set ent_cache and ent_cache.last_update in one line.

I'll try moving net_cache to global.

5 years ago

net_cache is now global in version 0.16.5.

5 years ago
(updated 5 years ago)

Thanks.
If we get any more desyncs from our mod pack I'll check the script.dat and confirm there are no mod global variations between client and server for Recursive Blueprints πŸ™‚

New response