scredis / scredis

Non-blocking, ultra-fast Scala Redis client built on top of Akka IO.

Home Page:https://scredis.github.io/scredis/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Empty password ("") stuck requests

Newbas opened this issue · comments

Version: 2.3.6

If the password left empty, using environment variables to define a password and got an empty password then it does not work anymore. New requests go into a queue, but it is not processed and just growing.

Providing the wrong password works better, just shows the wrong Auth message and after everything works. =)

Looks like issue is here, auth marked as successful
https://github.com/scredis/scredis/blob/v2.3.6/src/main/scala/scredis/io/ListenerActor.scala#L107

case auth @ Auth(password) => if (password.isEmpty) {
    passwordOpt = None
    auth.success(())
}

But state not changed, Recieve not updated and queue not processing, Suppose it needs something like this called

onInitialized()
sendAllQueuedRequests()
if (isShuttingDown) {
  become(shuttingDown)
} else {
  become(initialized)
}

And this already used twice so looks like candidate for function.
Thanks.

Thanks for reporting,

could you provide a little more info what is going on, empty password is considered no password right now.
It is possible not to require password for Redis. I am not sure password can be empty string, is that an issue?

What is a sequence of actions you do?

  1. Start Redis server with password ""?
  2. Start Redis client with password="" ?
  3. messages are queueing but are not sent to server? When you are not authenticated all requests should fail with N0_AUTH actually

I suppose i missed one thing,

https://github.com/scredis/scredis/blob/v2.3.6/src/main/scala/scredis/io/ListenerActor.scala#L310

val authRequestOpt = passwordOpt.map { password =>
  Auth(password)
}

And after
https://github.com/scredis/scredis/blob/v2.3.6/src/main/scala/scredis/io/ListenerActor.scala#L341

if (initializationRequestsCount > 0) {

So this means then if no password Option is empty and there are no requests for initialization and it goes in else
https://github.com/scredis/scredis/blob/v2.3.6/src/main/scala/scredis/io/ListenerActor.scala#L344

That will call all initializers. But a blank password will have init requests and will try to send it without this block.

Sorry, got messed through debugging, checked both started to write one, then another and in the end, lost connection between them.

So if you have a blank password ("") it does not work, None works fine. For empty password ("") redis restart making it work.

And my code is

val client = Client()
client.get[String](key).onComplete{res => 
  //never happens for me
}

And config

scredis {
    redis {
        host = ${REDIS_HOST}
        password = ${REDIS_PASSWORD}
    }
    io {
        receive-timeout = 5 seconds
    }
    akka {
      decoder-dispatcher {
        mailbox-type = "akka.dispatch.BoundedMailbox"
        mailbox-capacity = 1024
        throughput = 1024
      }
    }
}

And REDIS_PASSWORD is empty, so it is ""

While debugging i thought some issues with connection or timeout, but I saw connection exists in redis, so checked in code. And saw that all my requests still in queue.
https://github.com/scredis/scredis/blob/v2.3.6/src/main/scala/scredis/io/ListenerActor.scala#L56

If empty string should work same as no password, then I suppose something like that should do the trick, and Auth part can be removed.
https://github.com/scredis/scredis/blob/v2.3.6/src/main/scala/scredis/io/ListenerActor.scala#L310

val authRequestOpt = passwordOpt.map {
  case Some(password) if password.nonEmpty => Auth(password)
  case _ => None
}

Okay empty string is a valid password, fix in #140

Luckily enough you can auth with any password if password is not set in redis server, this should not break for anyone relaying on "" as no password.