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

Memcache write-read error #340

Open
leesf opened this issue Jan 2, 2017 · 0 comments
Open

Memcache write-read error #340

leesf opened this issue Jan 2, 2017 · 0 comments

Comments

@leesf
Copy link

leesf commented Jan 2, 2017

Hello, everyone. When i use memcache in storehaus, there is an error. I change the memcache port to 12000. And the code is below

import com.twitter.storehaus.memcache.MemcacheStore
import com.twitter.conversions.time._
import com.twitter.finagle.redis.util.{CBToString, StringToChannelBuffer}
import com.twitter.util.Await

object MemcacheTest {
def main(args: Array[String]): Unit = {
val client = MemcacheStore.
defaultClient("memcache", "localhost:12000", 2, 10.seconds)
val store = MemcacheStore(client)

new Thread(new Runnable {
  override def run(): Unit =
  try {
    for (i <- 1 to 100000)
      store.put(i.toString, Some(StringToChannelBuffer(i.toString)))
  } catch {
    case e: Exception => e.printStackTrace
  }
}).start

new Thread(new Runnable {
  override def run(): Unit = {
  val start = System.currentTimeMillis()
    val num = "100"
    try {
      for (i <- 1 to 10)
        Await.result(store.get(num)) match {
          case Some(value) => println(CBToString(value))
          case None => {
            println("None")
          }
        }
    } catch {
      case e: Exception => e.printStackTrace
    }
  val end = System.currentTimeMillis()
  println((end - start)  + "")
}}).start

}
}

error info is below

com.twitter.finagle.ServiceTimeoutException: exceeded 10.seconds to memcache while creating a service/connection or reserving a service/connection from the service/connection pool memcache
at com.twitter.finagle.client.DefaultClient$$anonfun$14.apply(DefaultClient.scala:155)
at com.twitter.finagle.client.DefaultClient$$anonfun$14.apply(DefaultClient.scala:153)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at com.twitter.finagle.factory.Refinery.(Refinery.scala:20)
at com.twitter.finagle.client.DefaultClient$$anonfun$22.apply(DefaultClient.scala:220)
at com.twitter.finagle.client.DefaultClient$$anonfun$22.apply(DefaultClient.scala:220)
at com.twitter.finagle.builder.ClientBuilder.buildFactory(ClientBuilder.scala:849)
at com.twitter.finagle.builder.ClientBuilder.build(ClientBuilder.scala:882)
at com.twitter.finagle.memcached.KetamaClientBuilder.com$twitter$finagle$memcached$KetamaClientBuilder$$legacyFAClientBuilder$1(Client.scala:890)
at com.twitter.finagle.memcached.KetamaClientBuilder$$anonfun$build$1.apply(Client.scala:901)
at com.twitter.finagle.memcached.KetamaClientBuilder$$anonfun$build$1.apply(Client.scala:901)
at com.twitter.finagle.memcached.KetamaClient$$anonfun$9$$anonfun$10.apply(Client.scala:722)
at com.twitter.finagle.memcached.KetamaClient$$anonfun$9$$anonfun$10.apply(Client.scala:721)
at scala.Option.map(Option.scala:145)
at com.twitter.finagle.memcached.KetamaClient$$anonfun$9.apply(Client.scala:721)
at com.twitter.finagle.memcached.KetamaClient$$anonfun$9.apply(Client.scala:716)
at com.twitter.finagle.Group$$anonfun$map$1.applyOrElse(Group.scala:58)
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:33)
at com.twitter.finagle.Group$$anon$2$$anonfun$1$$anonfun$apply$1.applyOrElse(Group.scala:71)
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:33)
at scala.collection.TraversableLike$$anonfun$collect$1.apply(TraversableLike.scala:278)
at scala.collection.immutable.Set$Set1.foreach(Set.scala:74)
at scala.collection.TraversableLike$class.collect(TraversableLike.scala:278)
at scala.collection.AbstractTraversable.collect(Traversable.scala:105)
at com.twitter.finagle.Group$$anon$2$$anonfun$1.apply(Group.scala:70)
at com.twitter.finagle.Group$$anon$2$$anonfun$1.apply(Group.scala:68)
at com.twitter.util.Var$$anonfun$map$1.apply(Var.scala:53)
at com.twitter.util.Var$$anonfun$map$1.apply(Var.scala:53)
at com.twitter.util.Var$$anon$2$$anonfun$1.apply(Var.scala:66)
at com.twitter.util.Var$$anon$2$$anonfun$1.apply(Var.scala:65)
at com.twitter.util.Var$Observer.publish(Var.scala:153)
at com.twitter.util.UpdatableVar.observe(Var.scala:371)
at com.twitter.util.Var$$anon$2.observe(Var.scala:65)
at com.twitter.util.Var$class.observe(Var.scala:31)
at com.twitter.util.Var$$anon$2.observe(Var.scala:62)
at com.twitter.util.Var$class.observeTo(Var.scala:82)
at com.twitter.util.Var$$anon$2.observeTo(Var.scala:62)
at com.twitter.finagle.Group$class.ref(Group.scala:49)
at com.twitter.finagle.Group$$anon$2.ref$lzycompute(Group.scala:65)
at com.twitter.finagle.Group$$anon$2.ref(Group.scala:65)
at com.twitter.finagle.Group$class.members(Group.scala:87)
at com.twitter.finagle.Group$$anon$2.members(Group.scala:65)
at com.twitter.finagle.Group$class.apply(Group.scala:88)
at com.twitter.finagle.Group$$anon$2.apply(Group.scala:65)
at com.twitter.finagle.memcached.KetamaClient.(Client.scala:730)
at com.twitter.finagle.memcached.KetamaClientBuilder.build(Client.scala:896)
at com.twitter.storehaus.memcache.MemcacheStore$.defaultClient(MemcacheStore.scala:78)
at com.hust.grid.leesf.WrappedMemcacheStore.MemcacheTest$.main(MemcacheTest.scala:15)
at com.hust.grid.leesf.WrappedMemcacheStore.MemcacheTest.main(MemcacheTest.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

It seems the high concurrency read and write operation to memcache causes the problem. Any suggestions to solve it?

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

1 participant