Git Product home page Git Product logo

Comments (29)

debasishg avatar debasishg commented on July 28, 2024

Will it be possible to get a sample failing test case ?

from scala-redis.

dsturnbull avatar dsturnbull commented on July 28, 2024

I'm not sure. I can only get it to occur periodically. It seems like it only happens a little while after first initialising the client, about 5-10 mins. Do you think it sounds like the problem in issue #71?

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

I don't think it comes from setex. Because setex is handled exactly like set. And both of them return Boolean. Is it happening in the same piece of code every time ? I mean do u get the same stack trace every time it happens ? It will be helpful if u can share the piece of code that u think may be causing this.

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

also are u executing lua script or plain old scala code ?

from scala-redis.

dsturnbull avatar dsturnbull commented on July 28, 2024

The code running is (scala): redis.setex(key, 3600, "")
key is a string, usually about 70 bytes long.
And yeah, the same spot each time.

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

are u using the empty string as the value ?

from scala-redis.

dsturnbull avatar dsturnbull commented on July 28, 2024

Yeah.

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

that may cause the problem .. let me check .. I don't have access to the code right now. Will do it today evening.

from scala-redis.

dsturnbull avatar dsturnbull commented on July 28, 2024

Would you expect a non-empty string to be pretty assured of working well? I'll try that and report back.

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

should not happen that way .. but any more information will help .. because u r saying it happens intermittently. So empty string should not be a problem. But anyway please check and report if u get anything diff.

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

one more question .. are u using connection pool ? Or any kind of multi threaded setting ? Or just a plain single threaded mode of execution ? Since it's intermittent I have a feeling that some kind of race may be involved ..

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

I just got hold of the code and ran the following test ..

describe("set with empty value") {
    it("should set key/value pairs") {
      (1 to 100).foreach {a => 
        r.setex("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz-" + a, 3600, "") should equal(true)
      }
    }
  }

runs ok .. So I guess the problem is somewhere else ..

from scala-redis.

dsturnbull avatar dsturnbull commented on July 28, 2024

Definitely wasn't the contents of the value. I just had my process fail at the same time, with the same error on 5 different systems using "HELLO" as the value.

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

Could u please reply to the other question I asked earlier on the mode of execution - single threaded, multi-threaded, using pools etc. ?

from scala-redis.

dsturnbull avatar dsturnbull commented on July 28, 2024

Not sure, I assume single threaded. The client is created by new RedisClient(host, port).

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

I assume that the client u create is never accessed from multiple threads. Will it be possible to share some of the code that gives the problem ?

from scala-redis.

dsturnbull avatar dsturnbull commented on July 28, 2024

Well it's being used within storm, across 5 servers, each with 5 worker processes, each of which runs a couple of threads. Each creates its own redis client. This is on scala 2.8.2 btw.

The usage is, throughout 3-4 classes:

class BlahBolt extends BaseRichBolt {
  var redis: RedisClient = _

  def prepare(conf: util.Map[_, _], context: TopologyContext, collector: OutputCollector) {
    val host = conf.get("redis.host").asInstanceOf[String]
    val port = conf.get("redis.port").asInstanceOf[String].toInt
    redis = new RedisHelper(host, port).redis
  }

  def execute(input: Tuple) {
    val things = input.getValueByField("field").asInstanceOf[String].split(',')
    for (thing <- things) {
      redis.get[Array[Byte]](thing) match {
        case Some(bytes) => redis.setex(thing + "_set", 3600, "") // or "HELLO"
        case None =>
      }
    }
  }
}

class RedisHelper(host: String, port: Int) {
  val redis = new RedisClient(host, port)

  /* some other helpers like key creation and stuff */
}

The helper is an extra layer of indirection that I don't think is important to the problem here.. it could easily be replaced with new RedisClient(host, port) in the bolts.

from scala-redis.

dsturnbull avatar dsturnbull commented on July 28, 2024

Some other info. When this problem occurs, in IO.scala within the redis library:

  • in.available() == 1, until OOM
  • build.result().length grows infinitely

What could redis be sending that keeps the 'in' InputStream reading forever?

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

ah Scala 2.8.2 .. I was assuming 2.10. I will then test on 2.8.2 (need to create a separate environment). I remember we had some bug in the IO layer which I fixed. Will do that over the weekend. Thank you for the code snippet ..

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

One more thing .. which version of scala-redis are you using ?

from scala-redis.

dsturnbull avatar dsturnbull commented on July 28, 2024
<dependency>
    <groupId>net.debasishg</groupId>
    <artifactId>redisclient_2.8.1</artifactId>
    <version>2.3.1</version>
</dependency>

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

Do u have any plans to move to the latest version of scala and redisclient ?

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

In case u have the source and able to build, can u pls try with the following version of readLine in IO.scala ? I don't have the build environment right now ..

def readLine: Array[Byte] = {
    if(!connected) connect
    var delimiter = crlf
    var found: List[Int] = Nil
    var build = new scala.collection.mutable.ArrayBuilder.ofByte
    while (delimiter != Nil) {
      val next = in.read
      if (next < 0) return null
      if (next == delimiter.head) {
        found ::= delimiter.head
        delimiter = delimiter.tail
      } else {
        if (found != Nil) {
          delimiter = crlf
          build ++= found.reverseMap(_.toByte)
          found = Nil
        }
        build += next.toByte
      }
    }
    build.result
  }

from scala-redis.

dsturnbull avatar dsturnbull commented on July 28, 2024

Will be upgrading today, if all our dependencies compile ok. I also added if (next < 0) return null in our code now so I might see the results of that before the upgrade.

from scala-redis.

dsturnbull avatar dsturnbull commented on July 28, 2024

Returning early helps a lot, it doesn't get down to the infinite loop. It still fails the setex() though.

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

Do you get the same error ? Or anything different ..

from scala-redis.

dsturnbull avatar dsturnbull commented on July 28, 2024

Returning null made the client throw RedisConnectionDropped or something similar (don't have logs with me).

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

readLine can return null only when the read fails. In the current case, assuming that Redis server is up n running, I think it's encountering some characters which it fails to read properly. In your code I find the following line ..

val things = input.getValueByField("field").asInstanceOf[String].split(',')

which results in an array and the key of the setex is built based on these array elements. Can u please give a print of the values that "thing" takes across the loop iterations. And check on what value of "thing" you get the exception. I could not replicate the situation with my set of data.

from scala-redis.

dsturnbull avatar dsturnbull commented on July 28, 2024

Pretty sure this is a thread issue. I haven't seen it in the past week after changing things around to have one client per group of activity.

from scala-redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.