Comments (29)
Will it be possible to get a sample failing test case ?
from scala-redis.
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.
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.
also are u executing lua script or plain old scala code ?
from scala-redis.
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.
are u using the empty string as the value ?
from scala-redis.
Yeah.
from scala-redis.
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.
Would you expect a non-empty string to be pretty assured of working well? I'll try that and report back.
from scala-redis.
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.
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.
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.
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.
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.
Not sure, I assume single threaded. The client is created by new RedisClient(host, port)
.
from scala-redis.
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.
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.
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.
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.
One more thing .. which version of scala-redis are you using ?
from scala-redis.
<dependency>
<groupId>net.debasishg</groupId>
<artifactId>redisclient_2.8.1</artifactId>
<version>2.3.1</version>
</dependency>
from scala-redis.
Do u have any plans to move to the latest version of scala and redisclient ?
from scala-redis.
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.
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.
Returning early helps a lot, it doesn't get down to the infinite loop. It still fails the setex() though.
from scala-redis.
Do you get the same error ? Or anything different ..
from scala-redis.
Returning null made the client throw RedisConnectionDropped or something similar (don't have logs with me).
from scala-redis.
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.
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)
- Add support for variadic EXISTS
- How to create parser from object?
- How to use SSL Context to connect to Redis instance on AWS Elasticache with Encryption In-Transit enabled HOT 1
- Specify TTL for a key before pushing to Redis HOT 1
- Cannot find method "setCreated" in java.net.Socket. Unsupported JVM?
- Getting java.lang.Exception: Protocol error: Got (+,[B@38466868) as initial reply byte while pushing to redis quite frequently HOT 3
- Update: Missing stream commands XINFO, XADD, XTRIM, XDEL, XRANGE, XREVRANGE, XLEN, XREAD, XGROUP, XREADGROUP. XACK, XCLAIM, XAUTOCLAIM, XPENDING HOT 4
- Is server-assisted client side caching supported?
- Akka Dispatcher issue with scala redis
- How to add password to RedisClientPool? HOT 5
- "Exception: ERR wrong number of arguments f or 'expire' command" occurs when attempting to expire a key that contains spaces. HOT 11
- QUESTION - should `RedisClient` be shared or used as a singleton? HOT 3
- RedisClient in BATCH mode (for batchedPipeline) errors when sending commands to password-protected redis servers (initial AUTH command not sent) HOT 1
- can you support sentinel HOT 4
- Rate limit support
- Added LMOVE and BLMOVE but cannot test, blocked on PR
- Using with memcached redis protocol times out
- Read from lowest latency using AWS Elasticache Global datastore?
- Protocol errors while talking to Redis in Amazon ElasticCache HOT 1
- Publish release for Scala 3 + LTS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala-redis.