间谍 memcached 转换异常,可能的错误?

发布于 2024-12-17 19:38:41 字数 2473 浏览 4 评论 0原文

我在服务器日志中看到一个罕见的错误,很难追踪。我想知道会导致这样的异常,以便我可以确定我们的代码中发生了什么触发它?不幸的是,我没有重现的步骤,所以我无法确定是什么调用了代码导致了它。

           java.lang.ClassCastException: net.spy.memcached.MemcachedClient$5 cannot be cast to net.spy.memcached.ops.GetOperation$Callback
           at net.spy.memcached.protocol.ProxyCallback.addCallbacks(ProxyCallback.java:25)
           at net.spy.memcached.protocol.binary.OptimizedGetImpl.addOperation(OptimizedGetImpl.java:28)
           at net.spy.memcached.protocol.binary.OptimizedGetImpl.<init>(OptimizedGetImpl.java:21)
           at net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl.optimizeGets(BinaryMemcachedNodeImpl.java:46)
           at net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl.optimize(BinaryMemcachedNodeImpl.java:35)
           at net.spy.memcached.protocol.TCPMemcachedNodeImpl.fillWriteBuffer(TCPMemcachedNodeImpl.java:177)
           at net.spy.memcached.MemcachedConnection.handleWrites(MemcachedConnection.java:374)
           at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:326)
           at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:219)
           at net.spy.memcached.MemcachedClient.run(MemcachedClient.java:1591)

更新: 我相当确定这是我这边的违规代码:

    Future<CASValue<Object>> profiles;
    String userID = "OBFUSCATED";
    profiles = memClient.asyncGets("PROFILES_" + userID);

并且在间谍memcached中它应该运行:

 public <T> OperationFuture<CASValue<T>> asyncGets(final String key,
  final Transcoder<T> tc) {

final CountDownLatch latch = new CountDownLatch(1);
final OperationFuture<CASValue<T>> rv =
    new OperationFuture<CASValue<T>>(key, latch, operationTimeout);

Operation op = opFact.gets(key, new GetsOperation.Callback() {
  private CASValue<T> val = null;

  public void receivedStatus(OperationStatus status) {
    rv.set(val, status);
  }

  public void gotData(String k, int flags, long cas, byte[] data) {
    assert key.equals(k) : "Wrong key returned";
    assert cas > 0 : "CAS was less than zero: " + cas;
    val =
        new CASValue<T>(cas, tc.decode(new CachedData(flags, data,
            tc.getMaxSize())));
  }

  public void complete() {
    latch.countDown();
  }
});
rv.setOperation(op);
addOp(key, op);
return rv;
}

一切似乎都按顺序进行,它将正确接口的匿名实现放入队列中,稍后应该对其进行优化。我不知道问题发生在哪里。

There is an infrequent error that I see in my serverlogs which is hard to track down. I am wondering would cause such an exception so I can identify what in our code happens to trigger it? Unfortunately I don't have steps to reproduce so I can't identify what calls in out code cause it.

           java.lang.ClassCastException: net.spy.memcached.MemcachedClient$5 cannot be cast to net.spy.memcached.ops.GetOperation$Callback
           at net.spy.memcached.protocol.ProxyCallback.addCallbacks(ProxyCallback.java:25)
           at net.spy.memcached.protocol.binary.OptimizedGetImpl.addOperation(OptimizedGetImpl.java:28)
           at net.spy.memcached.protocol.binary.OptimizedGetImpl.<init>(OptimizedGetImpl.java:21)
           at net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl.optimizeGets(BinaryMemcachedNodeImpl.java:46)
           at net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl.optimize(BinaryMemcachedNodeImpl.java:35)
           at net.spy.memcached.protocol.TCPMemcachedNodeImpl.fillWriteBuffer(TCPMemcachedNodeImpl.java:177)
           at net.spy.memcached.MemcachedConnection.handleWrites(MemcachedConnection.java:374)
           at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:326)
           at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:219)
           at net.spy.memcached.MemcachedClient.run(MemcachedClient.java:1591)

Update:
I am fairly sure this is the offending code on my side:

    Future<CASValue<Object>> profiles;
    String userID = "OBFUSCATED";
    profiles = memClient.asyncGets("PROFILES_" + userID);

And in spy memcached it should run:

 public <T> OperationFuture<CASValue<T>> asyncGets(final String key,
  final Transcoder<T> tc) {

final CountDownLatch latch = new CountDownLatch(1);
final OperationFuture<CASValue<T>> rv =
    new OperationFuture<CASValue<T>>(key, latch, operationTimeout);

Operation op = opFact.gets(key, new GetsOperation.Callback() {
  private CASValue<T> val = null;

  public void receivedStatus(OperationStatus status) {
    rv.set(val, status);
  }

  public void gotData(String k, int flags, long cas, byte[] data) {
    assert key.equals(k) : "Wrong key returned";
    assert cas > 0 : "CAS was less than zero: " + cas;
    val =
        new CASValue<T>(cas, tc.decode(new CachedData(flags, data,
            tc.getMaxSize())));
  }

  public void complete() {
    latch.countDown();
  }
});
rv.setOperation(op);
addOp(key, op);
return rv;
}

Everything seems to be in order, it puts an anonymous implementation of the correct interface into the queue which should get optimized later. I am missing where the problem is occurring.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪意 2024-12-24 19:38:41

这是bug 96,已于 7 月修复。您正在运行旧版本。

This was bug 96, fixed in July. You're running an old version.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文