Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"databases" misreported #775

Open
mgravell opened this issue Nov 6, 2024 · 4 comments
Open

"databases" misreported #775

mgravell opened this issue Nov 6, 2024 · 4 comments
Assignees

Comments

@mgravell
Copy link
Contributor

mgravell commented Nov 6, 2024

Describe the bug

The following is unexpected:

> config get databases
* 2
 [0]$ databases
 [1]$ 16
> select 1
- ERR invalid database index.

If select isn't fully implemented, databases should probably report 1. Reporting 16 but erroring if trying to change the database is... weird.

Steps to reproduce the bug

select 1 (or anything else greater than zero and less than the reported databases)

note that select 0 works fine and as expected

I suspect the real "bug" here is in config get, in particular databases

Expected behavior

No response

Screenshots

No response

Release version

No response

IDE

No response

OS version

No response

Additional context

No response

@Vijay-Nirmal
Copy link
Contributor

Vijay-Nirmal commented Nov 6, 2024

Looks like if the cluster mode is enabled config get databases return as 16 else 1. Since Garnet doesn't support multiple database (#61), I think we should always return 1 . I can raise a PR if Garnet team is fine with this change. Just a small change.

ServerConfigType.DATABASES => storeWrapper.serverOptions.EnableCluster ? "$9\r\ndatabases\r\n$1\r\n1\r\n"u8 : "$9\r\ndatabases\r\n$2\r\n16\r\n"u8,

Edit: Looks like if the cluster mode is enabled then we should get an error even in SELECT 0. I will dig deeper soon

if (storeWrapper.serverOptions.EnableCluster)
{
// Cluster mode does not allow DBID
while (!RespWriteUtils.WriteError(CmdStrings.RESP_ERR_GENERIC_SELECT_CLUSTER_MODE, ref dcurr, dend))
SendAndReset();
}

@vazois
Copy link
Contributor

vazois commented Nov 7, 2024

For cluster mode, I think right now we are on par with Redis. We are basically returning the following. I guess the only difference is that Redis executes successfully for SELECT 0, so that might need to be fixed.
Image

For the standalone, I guess it makes sense to advertise databases = 1. I am not sure though if there is any expectation from the clients to observe a value of 16. @mgravell, is there such thing? If not, then should be fine to return databases = 1.
Let me know if you are going to create a PR for this or else I can do it. It should be simple fix.

@rnz
Copy link

rnz commented Nov 9, 2024

@vazois
May be better implement namespacing - #415 ?

Also redis support not only 16 databases, this parameter can be configured https://github.com/valkey-io/valkey/blob/45d596e1216472e49b9f950a4b9a040b6e87add6/valkey.conf#L396C1-L396C13

@mgravell
Copy link
Contributor Author

mgravell commented Nov 10, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants