The current version of Redis includes a Lua interpreter that uses the number type, which is a 64bit floating point number. This interacts poorly with some Redis functions, like INCR and all its siblings that work on the full 64bit integer number space. Apparently it is possible to get Lua to work with both 64bit floating point and 64bit integers, which I think would be ideal, allowing the safe manipulation and conversion between Redis and Lua types. The number range supported by Lua effectively limits integer operations and numeric comparisons to numbers less than or equal to the greatest 52bit integer.

Comment From: itamarhaber

Hello @johanbrandhorst

Lua's support for 64b integers has been added in v5.3 (of Lua), whereas Redis uses v5.1. To support this in Redis, the Lua engine would have to be upgraded to that version.

Regrettably, the upgrade isn't straightforward as Lua made some breaking API changes between these versions. The concern is that by upgrading the embedded Lua engine, Redis will not be backward compatible with earlier scripts as well, hence it was not done until now.

Comment From: johanbrandhorst

@itamarhaber Thank you for that clarification, do we have any plans for migrating or is it out of the question for the forseeable future? Perhaps something like a 6.0 with an upgraded Lua engine?

Comment From: itamarhaber

The plans are up to @antirez to make and execute, but that could definitely be an item in them :)

A couple of extra thoughts: 1. To mitigate breakage of existing scripts, the 5.3 engine could be introduced as experimental via. a compile or (even better) runtime switch. 2. Some of the breaking changes could be perhaps worked around by tweaking the sandbox to support some of the 5.1 api in 5.3 (I vaguely remember something about table lib). 3. Nowadays, we have modules. It should be possible to wrap 5.3 as a custom module that offers most of the embedded's functionality, with caching and replication being the two big challenges to solve. That said, this could be a viable long-term approach to adding support for ~Ruby~ ~Python~ ~JavaScript~ other languages and their respective versions.

Comment From: zcaudate

I'm curious if there are any plans/roadmap for an upgrade to 5.3+ in the near future

Comment From: oranagra

@zcaudate yes, this is being worked on (see #8180), but it may only become a reality in redis 7.0.

Comment From: zcaudate

@oranagra oh this is awesome. thanks for the update.

Comment From: tianshuang

Any update?

Comment From: oranagra

sorry for the luck of update, an update was posted in the above referenced #8180. and also just posted it in #7382 (and closed it).

in essence, we concluded that we can't afford to upgrade to Lua 5.4 since it's not backwards compatible with 5.1 and it could break many existing scripts. We do consider adding Java Script support in the near future, so maybe that can resolve the problem mentioned in this issue.

Comment From: szmcdull

no, JS does not support 64bit integer

Comment From: sundb

@szmcdull BigInt in js?