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

Hedis hangs on reading big zset #15

Closed
k-bx opened this issue Jun 24, 2014 · 8 comments
Closed

Hedis hangs on reading big zset #15

k-bx opened this issue Jun 24, 2014 · 8 comments

Comments

@k-bx
Copy link
Collaborator

k-bx commented Jun 24, 2014

Here is a piece of code:

{-# LANGUAGE OverloadedStrings #-}

import Database.Redis
import System.Random
import qualified Data.ByteString.Char8 as BC8

main :: IO ()
main = do
  conn <- connect (defaultConnectInfo { connectHost="localhost" })

  stdGen <- getStdGen
  runRedis conn (fillBigZset stdGen 20000)

  resp <- runRedis conn $ zrangebyscoreLimit "bigzset" 0 1403194724 0 15000
  putStrLn $ "Response: " ++ show resp
  return ()

fillBigZset :: (RedisCtx m f, RandomGen t)
            => t -> Int -> m ()
fillBigZset _ 0 = return ()
fillBigZset gen n = do
    let (v, newGen) = randomR (1,1000000) gen
    _ <- zadd "bigzset" [(v, BC8.pack ("value-value-value-value-value-" ++ show v))]
    fillBigZset newGen (n - 1)

You can comment out 2 lines that fill redis after first time you run it. On my machine, this hangs with redis 2.6. Also tried with latest 2.8 one.

strace output: https://gist.github.com/k-bx/cd3cb178412ea9c50e71

@Davorak
Copy link

Davorak commented Jun 25, 2014

It looks like this bug is only present when the library is compiled with profiling on. I recompiled with profiling off and this bug went away.

The tip off to look examine the weather the profiling level was on or off was the repeated use of rt_sigreturn in the strace output which can be utilized when library profiling is turned on, or so I remember, unfortunately I can not find the link at the moment.

@k-bx
Copy link
Collaborator Author

k-bx commented Jun 25, 2014

Just tried GHC 7.8. Profiling-enabled hedis still goes into the loop. Profiling-disabled finishes it's work, but instead of result prints "RedisBug: ConnectionLost" twice,

strace for non-profiling version run:
.tar.xz (36Kb): https://dl.dropboxusercontent.com/u/865508/RedisBug.strace.stdout.tar.xz
.txt (1.8 Mb): https://dl.dropboxusercontent.com/u/865508/RedisBug.strace.stderr

@k-bx
Copy link
Collaborator Author

k-bx commented Jun 25, 2014

Update: played a bit with non-profiling version. Most of the time it does hang, sometimes it works good, and I saw this "ConnectionLost" only when running with strace.

@k-bx
Copy link
Collaborator Author

k-bx commented Jun 26, 2014

Seems part of hang is due to attoparsec bug haskell/attoparsec#70

Downgrading to 0.11.3.4 helps.

@Davorak mentioned that this doesn't fix all errors, since code from original report still fails on his machine with 0.11 versions of attoparsec producing output

KonRedisTest: <socket: 3>: hFlush: illegal operation (handle is closed)
KonRedisTest: <socket: 3>: hFlush: illegal operation (handle is closed)

@ozataman
Copy link

ozataman commented Sep 4, 2014

Also got bitten by this while using hedis and had to downgrade to < attoparsec 0.12. Is there a fix in sight? Specifically, rpop on a fairly large value hangs indefinitely.

@k-bx
Copy link
Collaborator Author

k-bx commented Sep 4, 2014

@ozataman fix is quite straight-forward -- fix attoparsec's behaviour and make a pull-request!

@ozataman
Copy link

ozataman commented Sep 4, 2014

Thanks, but we can’t all be solving all the problems we encounter in OSS. I was more interested in bumping the issue and finding out if anybody had anything in the works.
On Sep 4, 2014, at 3:26 AM, Konstantine Rybnikov notifications@github.com wrote:

@ozataman fix is quite straight-forward -- fix attoparsec's behaviour and make a pull-request!


Reply to this email directly or view it on GitHub.

@k-bx
Copy link
Collaborator Author

k-bx commented Jan 6, 2015

So, this is now working with latest attoparsec.

@k-bx k-bx closed this as completed Jan 6, 2015
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

3 participants