uuid4 generator uuid reduplicate in nginx
zhaojp0411 opened this issue · comments
at same time
what?
Well I guess fix is to use http://wiki.nginx.org/HttpLuaModule#init_by_lua to create global uuid4 object and use it for generating all uuids, because of problems described in http://lua-users.org/wiki/MathLibraryTutorial "math.random , math.randomseed" section.
init_by_lua 'uuid4 = require "uuid4"';
Thanks for that comment, @intarstudents. I'm not familiar with nginx's lua capabilities but generally the uuid4 will get a time-based seed when the module first loads; implementors are encouraged to use better sources of random seeds if they have them. Loading a module once (as described by @intarstudents's) is better than loading it many times.