pinpoint-apm/pinpoint · error · RuntimeException

ServiceType code of ${pair} is duplicated with ${prev}

Error message

ServiceType code of ${pair} is duplicated with ${prev}

What it means

Thrown by TraceMetadataLoader.ServiceTypeChecker.check when two TraceMetadataProviders register ServiceTypes with the same numeric code, detected because the second put into serviceTypeCodeMap returns the previously registered pair. Duplicate codes make agent/server type resolution ambiguous, so metadata loading aborts with a RuntimeException. The input at fault is the ServiceType whose code collides; plugin authors must allocate unique ServiceType codes (or fix conflicting registrations) before loading.

Source

Thrown at commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/trace/TraceMetadataLoader.java:222

    
    private class ServiceTypeChecker {
        private final Map<String, Pair<ServiceType>> serviceTypeNameMap = new HashMap<>();
        private final Map<Short, Pair<ServiceType>> serviceTypeCodeMap = new HashMap<>();

        private void check(ServiceType type, TraceMetadataProvider provider) {
            Pair<ServiceType> pair = new Pair<>(type, provider);
            Pair<ServiceType> prev = serviceTypeNameMap.put(type.getName(), pair);
    
            if (prev != null) {
                // TODO change exception type
                throw new RuntimeException("ServiceType name of " + serviceTypePairToString(pair) + " is duplicated with " + serviceTypePairToString(prev));
            }
    
            prev = serviceTypeCodeMap.put(type.getCode(), pair);
    
            if (prev != null) {
                // TODO change exception type
                throw new RuntimeException("ServiceType code of " + serviceTypePairToString(pair) + " is duplicated with " + serviceTypePairToString(prev));
            }

            if(type.isAlias()){
                if(!type.isRpcClient()){
                    throw new RuntimeException("ServiceType code of " + serviceTypePairToString(pair) + " should be between range of RPC");
                }
                if(type.isRecordStatistics()){
                    throw new RuntimeException("ServiceType code of " + serviceTypePairToString(pair) + " can't have ALIAS and RECORD_STATISTICS at the same time");
                }
            }
        }

        private void logResult() {
            logger.info("Finished loading ServiceType:");

            List<Pair<ServiceType>> serviceTypes = new ArrayList<>(serviceTypeCodeMap.values());
            serviceTypes.sort(Comparator.comparingInt(this::getCode));

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Assign a unique code to your custom ServiceType within the plugin-reserved range
  2. Remove or update the conflicting provider jar
  3. Keep a registry of allocated codes across internal plugins
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/trace/TraceMetadataLoader.java:222 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/34614489025f2c3e. Report an issue: GitHub.