{"record":{"id":"d39fd5aafe22ccde","repo":"pinpoint-apm/pinpoint","slug":"duplicated-span-found","errorCode":null,"errorMessage":"duplicated span found:{}","messagePattern":"duplicated span found:(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"web/src/main/java/com/navercorp/pinpoint/web/applicationmap/map/FilteredMapBuilder.java","lineNumber":312,"sourceCode":"        final Dot dot = this.dotExtractor.newDot(span);\n        this.dotExtractor.addDot(srcApplication, dot);\n    }\n\n    private MultiValueMap<Long, SpanBo> createTransactionSpanMap(List<SpanBo> transaction) {\n        final MultiValueMap<Long, SpanBo> transactionSpanMap = new LinkedMultiValueMap<>(transaction.size());\n        for (SpanBo span : transaction) {\n            if (span.getTraceSourceType() == TraceSourceType.OPENTELEMETRY) {\n                if (isParentSpanId(span.getSpanId(), transaction)) {\n                    transactionSpanMap.add(span.getSpanId(), span);\n                }\n\n                createOpenTelemetryTransactionSpanMap(transaction, transactionSpanMap, span, span.getSpanEventBoList());\n                for (SpanChunkBo spanChunkBo : span.getSpanChunkBoList()) {\n                    createOpenTelemetryTransactionSpanMap(transaction, transactionSpanMap, span, spanChunkBo.getSpanEventBoList());\n                }\n            } else {\n                if (transactionSpanMap.containsKey(span.getSpanId())) {\n                    logger.warn(\"duplicated span found:{}\", span);\n                }\n                transactionSpanMap.add(span.getSpanId(), span);\n            }\n        }\n        return transactionSpanMap;\n    }\n\n    private void createOpenTelemetryTransactionSpanMap(List<SpanBo> transaction, MultiValueMap<Long, SpanBo> transactionSpanMap, SpanBo span, List<SpanEventBo> spanEventBoList) {\n        for (SpanEventBo spanEventBo : spanEventBoList) {\n            long spanId = OpenTelemetryAnnotationValueUtils.getSpanId(spanEventBo.getAnnotationBoList());\n            if (spanId != OpenTelemetryAnnotationValueUtils.DEFAULT_SPAN_ID) {\n                if (isParentSpanId(spanId, transaction)) {\n                    transactionSpanMap.add(spanId, span);\n                }\n            }\n        }\n    }\n","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/map/FilteredMapBuilder.java#L294-L330","documentation":"FilteredMapBuilder builds a transaction span map keyed by spanId while constructing a filtered application map. When two SpanBo objects share the same spanId, the second overwrites or is flagged as a duplicate via this warning. Pinpoint expects spanIds to be unique within a transaction; duplicates indicate corrupted or duplicated trace data from HBase.","triggerScenarios":"A filtered trace query returns multiple SpanBo rows with the same spanId (e.g. duplicate span rows written to HBase, span retry/re-serialization, or a span whose spanId collides due to generator misconfiguration).","commonSituations":"HBase replication glitches or region-server retries writing the same span twice; agent-side spanId duplication after clock/ID-generator misconfiguration; replaying/importing trace dumps into HBase.","solutions":["Check why the agent emitted duplicate spanIds (agent version bugs, ID generator issues) and upgrade the agent","Scan/deduplicate the span rows in HBase for the affected transactionId","Verify HBase write path (replication, retry configuration) is not duplicating rows","If duplicates are expected and harmless, confirm the map-add overwrites deterministically; otherwise treat the second span as corrupted data"],"exampleFix":"// before\nif (transactionSpanMap.containsKey(span.getSpanId())) {\n    logger.warn(\"duplicated span found:{}\", span);\n}\ntransactionSpanMap.add(span.getSpanId(), span);\n// after\nSpanBo previous = transactionSpanMap.putIfAbsent(span.getSpanId(), span);\nif (previous != null) {\n    logger.warn(\"duplicated span found:{} (keeping first)\", span);\n}","handlingStrategy":"validation","validationCode":"// before building the map, detect duplicate spanIds\nSet<Long> seen = new HashSet<>();\nfor (SpanBo span : spans) {\n    if (!seen.add(span.getSpanId())) {\n        logger.warn(\"duplicate spanId {} in transaction {}\", span.getSpanId(), span.getTransactionId());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep agent and collector versions consistent to avoid duplicate span writes","Monitor for duplicate spanId warnings as a data-integrity signal","Validate HBase replication/retry settings that can re-write rows"],"tags":["pinpoint","distributed-tracing","data-integrity"],"backgroundTag":"internal-invariant-violation","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"}