[Rseding91] [0.17.21] on_init global table order not consistent between server/client.

This subforum contains all the issues which we already resolved.
Oarc
Fast Inserter
Fast Inserter
Posts: 121
Joined: Sun Sep 18, 2016 2:04 pm
Contact:

[Rseding91] [0.17.21] on_init global table order not consistent between server/client.

Post by Oarc »

I tracked this down from a desync in my scenario originally. With the help of Discord folks.

Looks like global tables, created during on_init, with length > 1024 don't have consistent ordering when iterating on server vs client later using "for k,v in pairs()"

My server is linux headless on ubuntu, client is windows steam. Not sure if you need more details on the platform differences... let me know if you do.

This is my control.lua file:

Code: Select all

script.on_init(function()
  global.test_table = {}
  for i = 1, 34 do
    for j = 1, 34 do
      table.insert(global.test_table, { x=i, y=j })
    end
  end
end)
To get a log to view the differences I ran this in game:

Code: Select all

/c for k,v in pairs(global.test_table) do log(k) end

The end result is that when I compare my server vs client log files I found this:

Server Log:

Code: Select all

  69.107 Script for k,v in pairs(global.test_table) do log(k) end:1: 1019
  69.107 Script for k,v in pairs(global.test_table) do log(k) end:1: 1020
  69.107 Script for k,v in pairs(global.test_table) do log(k) end:1: 1021
  69.107 Script for k,v in pairs(global.test_table) do log(k) end:1: 1022
  69.107 Script for k,v in pairs(global.test_table) do log(k) end:1: 1023
  69.107 Script for k,v in pairs(global.test_table) do log(k) end:1: 1024
  69.108 Script for k,v in pairs(global.test_table) do log(k) end:1: 1025
  69.108 Script for k,v in pairs(global.test_table) do log(k) end:1: 1026
  69.108 Script for k,v in pairs(global.test_table) do log(k) end:1: 1027
  69.108 Script for k,v in pairs(global.test_table) do log(k) end:1: 1028
Client Log:

Code: Select all

 152.705 Script for k,v in pairs(global.test_table) do log(k) end:1: 1019
 152.705 Script for k,v in pairs(global.test_table) do log(k) end:1: 1020
 152.705 Script for k,v in pairs(global.test_table) do log(k) end:1: 1021
 152.705 Script for k,v in pairs(global.test_table) do log(k) end:1: 1022
 152.705 Script for k,v in pairs(global.test_table) do log(k) end:1: 1023
 152.705 Script for k,v in pairs(global.test_table) do log(k) end:1: 1024
 152.705 Script for k,v in pairs(global.test_table) do log(k) end:1: 1050 <--- PROBLEM?
 152.705 Script for k,v in pairs(global.test_table) do log(k) end:1: 1049
 152.705 Script for k,v in pairs(global.test_table) do log(k) end:1: 1048
 152.705 Script for k,v in pairs(global.test_table) do log(k) end:1: 1047
 
Rseding91
Factorio Staff
Factorio Staff
Posts: 14339
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.17.21] on_init global table order not consistent between server/client.

Post by Rseding91 »

Thanks for the report. It looks like the problem is with the serpent library we use for saving/loading script state. When I run the table through save/load it changes the key order even on my local machine.

I'll look into it and figure out how to get it fixed.
If you want to get ahold of me I'm almost always on Discord.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14339
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Rseding91] [0.17.21] on_init global table order not consistent between server/client.

Post by Rseding91 »

Ok, it's now fixed for the next version of 0.17.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Resolved Problems and Bugs”