Strange bug; where to start looking?
tsuna
tsunanet at gmail.com
Thu Jan 6 14:05:25 EST 2011
On Thu, Jan 6, 2011 at 10:09 AM, jgalyan <jgalyan at adbrite.com> wrote:
> I have a strange bug that I'm sure is due to something I've done wrong, and
> I'm not sure where to look for possible causes. The behavior I'm seeing is,
> for each request I send to my Netty-based server, my handler code gets
> called twice. In my handler code, I then send an outbound request to a
> memcached server, which results in my handler code getting called twice
> again for each (with my bug), for a total of four additional iterations
> through the code.
>
> I'm using a ReplayingDecoder in my client pipeline (the part that handles
> responses from memcached), since we're chunking our data, and responses are
> usually too big to fit in one packet. I don't think this is the problem,
> though, because the client pipeline doesn't invoke the server pipeline, and
> I'm seeing the server pipeline getting invoked twice for each incoming
> request.
Something similar happened to me and it was due to me misusing
ReplayingDecoder – I had a couple of unintended side-effects prior to
the full-deserialization of the message with ReplayingDecoder. You
should double-check that you haven't made a similar mistake.
What I've found useful was to add some logging statements with a stack
trace whenever my handled is called, something akin to:
LOG.error("Entering handler", new RuntimeException("trace"));
If you match up the line numbers in the stack trace with those in your
code and Netty's code, it's fairly easy to rule out the possibility of
misusing ReplayingDecoder.
--
Benoit "tsuna" Sigoure
Software Engineer @ www.StumbleUpon.com
More information about the netty-users
mailing list