tenplus1/money — pull request #1 by me4 (2014-12-02 08:39:54+00:00)
Title: Change storage to allow more users

This might be useful, or otherwise I'll remove this.

The old "accounts" file format stores a serialization of the accounts table, which includes a nested table for each user. That causes the server to crash when the table reaches 32,768 user entries (or 131,072 when not using LuaJIT). The crash is due to minetest.deserialize returning nil along with an ignored error string "main function has more than 65536 constants", and then accessing the accounts table which was set to nil.

This is a limitation in LuaJIT caused by the large number of nested tables. This commit splits the accounts table into two simpler tables, accounts_money and accounts_frozen, and stores them in their own files of the same name. I am now able to have over 2 million users with LuaJIT before things start throwing a "not enough memory" exception. Not using LuaJIT is still limited to 131,072 users though.

I used a Perl script to convert the old "accounts" file into the new "accounts_money" and "accounts_frozen" files: https://gist.github.com/me4/6a2fee3420b1b30d5ad9