{"record":{"id":"161705b9c8d585b8","repo":"pinpoint-apm/pinpoint","slug":"can-not-find-suitable-parentspan-currentspan","errorCode":null,"errorMessage":"Can not find suitable ParentSpan.(CurrentSpan:{})","messagePattern":"Can not find suitable ParentSpan\\.\\(CurrentSpan:(.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"web/src/main/java/com/navercorp/pinpoint/web/applicationmap/map/FilteredMapBuilder.java","lineNumber":416,"sourceCode":"        } else {\n            for (SpanBo parentSpanCandidate : parentSpanCandidateList) {\n                SpanAcceptor acceptor = new SpanReader(Collections.singletonList(parentSpanCandidate));\n                boolean accept = acceptor.accept(new SpanVisitor() {\n                    @Override\n                    public boolean visit(BasicSpan basicSpan, SpanEventBo spanEventBo) {\n                        if (spanEventBo.getNextSpanId() == currentSpan.getSpanId()) {\n                            return SpanVisitor.ACCEPT;\n                        }\n                        return SpanVisitor.REJECT;\n                    }\n                });\n\n                if (accept) {\n                    return parentSpanCandidate;\n                }\n            }\n\n            logger.warn(\"Can not find suitable ParentSpan.(CurrentSpan:{})\", currentSpan);\n            return parentSpanCandidateList.get(0);\n        }\n    }\n\n    private void addNodeFromSpanEvent(SpanBo span, Application srcApplication, MultiValueMap<Long, SpanBo> transactionSpanMap) {\n        /*\n         * add span event statistics\n         */\n        LinkDataMap sourceLinkDataMap = linkDataDuplexMap.getSourceLinkDataMap();\n\n        SpanAcceptor acceptor = new SpanReader(Collections.singletonList(span));\n        acceptor.accept(new SpanVisitor() {\n            @Override\n            public boolean visit(BasicSpan basicSpan, SpanEventBo spanEventBo) {\n                if (basicSpan instanceof SpanBo spanBo) {\n                    addNode(spanBo, transactionSpanMap, srcApplication, sourceLinkDataMap, spanEventBo);\n                }\n                return SpanVisitor.REJECT;","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/map/FilteredMapBuilder.java#L398-L434","documentation":"When linking a span to its parent in the filtered map, getParentsSpan searches candidate parent spans (async or same-transaction spans) for one whose spanId matches the current span's parentSpanId and which is accepted. If no candidate matches, it falls back to the first candidate and logs this warning. The resulting link may connect the wrong parent.","triggerScenarios":"A span's parentSpanId does not match any span in the transactionSpanMap's candidates — e.g. the parent span was filtered out, async spans referencing a missing parent, or parent spans not yet collected by the query.","commonSituations":"Trace filters that exclude the root/parent span; async/continuation traces where the parent lives in a different collector window; agents producing async spans whose parent span is dropped by sampling.","solutions":["Widen the filter or time range so the parent span is included in the queried trace","Verify the agent correctly records parentSpanId for async spans (upgrade agent if buggy)","Check whether expectedParentSpanId truly exists in HBase for this transactionId","If fallback is acceptable, treat the warning as informational; otherwise reject incomplete traces"],"exampleFix":"// before\nlogger.warn(\"Can not find suitable ParentSpan.(CurrentSpan:{})\", currentSpan);\nreturn parentSpanCandidateList.get(0);\n// after\nlogger.warn(\"Can not find suitable ParentSpan.(CurrentSpan:{}) candidates:{}\", currentSpan, parentSpanCandidateList.size());\nreturn parentSpanCandidateList.stream()\n    .filter(s -> s.getSpanId() == currentSpan.getParentSpanId())\n    .findFirst()\n    .orElse(parentSpanCandidateList.get(0));","handlingStrategy":"fallback","validationCode":"// verify the parent span exists before linking\nboolean parentExists = spans.stream()\n    .anyMatch(s -> s.getSpanId() == currentSpan.getParentSpanId());\nif (!parentExists) {\n    logger.warn(\"parent spanId {} missing; link may be inaccurate\", currentSpan.getParentSpanId());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure filters/time ranges include parent spans of async children","Keep async span parentSpanId handling up to date with agent upgrades","Treat this warning as a hint of incomplete trace data, not a fatal error"],"tags":["pinpoint","distributed-tracing","async"],"backgroundTag":"entity-not-found","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}