Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Lua scripts ignore SELECT and always run against database 0

Open
#2,258 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 2 days

@kevin-montrose is already working on this.

Since Oct 20, 2026.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
backend, databases

Research direction

Start at Garnet's EVAL and EVALSHA handling and trace how Lua commands select the database for Redis calls. Reproduce with the issue's SELECT 1 sequence, with LuaTransactionMode both on and off. Done means scripts read and write database 1 after SELECT 1, matching plain commands and Redis behavior.

Written by the indexing model from the issue text.

Description

After SELECT 1, EVAL and EVALSHA still read and write database 0. Plain commands on the same connection use database 1 as expected.

Repro against a fresh GarnetServer 2.2.3 (win-x64 release zip) with EnableLua: true and MaxDatabases: 16, same result with LuaTransactionMode on or off:

SELECT 1                                         -> OK
SET k from-db1                                   -> OK
GET k                                            -> "from-db1"
EVAL "return redis.call('get', KEYS[1])" 1 k     -> (nil)        expected "from-db1"
EVALSHA <sha of the same script> 1 k             -> (nil)        expected "from-db1"
EVAL "return redis.call('set', KEYS[1], 'from-lua')" 1 k2   -> OK
GET k2                                           -> (nil)        expected "from-lua"
SELECT 0
GET k2                                           -> "from-lua"   the script wrote to database 0

On Redis the script runs in the connection's selected database, so both reads return from-db1 and k2 lands in database 1.

This breaks libraries that keep their keys in another database and use Lua, for example a distributed lock (Medallion.Threading.Redis extends and releases its lock with Lua scripts) on a GetDatabase(1): the scripts never find the lock key.

Dominant language
C#
Stars
12.1k
Forks
716
Avg merge
2d 1h
Merged PRs (30d)
69

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/garnet

All issues in microsoft/garnet

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.