skywalking icon indicating copy to clipboard operation
skywalking copied to clipboard

Possible segment ref data loss in the zipkin receiver plugin

Open yangyshdan opened this issue 7 years ago • 1 comments

Please answer these questions before submitting your issue.

  • Why do you submit this issue? Bug

Bug

  • Which version of SkyWalking, OS and JRE? JRE

  • Which company or project? School research project

  • What happen? If possible, provide a way for reproducing the error. e.g. demo application, component version.

In the code of SegmentBuilder.java in the initSpan function, there is a piece of code which is listed below.

        switch (kind) {
            case CLIENT:
                spanBuilder.setSpanType(SpanType.Exit);
                String peer = getPeer(parentSpan, span);
                if (peer != null) {
                    spanBuilder.setPeer(peer);
                }
                clientSideSpan = new ClientSideSpan(span, spanBuilder);
                clientPartSpan.put(span.id(), clientSideSpan);
                break;
            case SERVER:
                spanBuilder.setSpanType(SpanType.Entry);
                this.buildRef(spanBuilder, span, parentSegmentSpan, parentSpan);
                break;

Notice that clientPartSpan.put(span.id(), clientSideSpan); will set the client span in cache so that when server span arrived, it will fetch client span and build the segment reference.

However, the spans' arriving order is totally random. We can not gurantee that client span will arrive before server span. If server span arrives before client span, the segement ref building process will fail.

This happens several time in my local environment.

yangyshdan avatar Sep 26 '19 14:09 yangyshdan

Read #2653

wu-sheng avatar Sep 27 '19 02:09 wu-sheng