{"record":{"id":"771f912af479281b","repo":"pinpoint-apm/pinpoint","slug":"agent-already-started","errorCode":null,"errorMessage":"Agent already started.","messagePattern":"Agent already started\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/DefaultAgent.java","lineNumber":214,"sourceCode":"            return Paths.get(location);\n        }\n        return agentPath;\n    }\n\n\n    private void preloadOnStartup() {\n        // Preload to fail fast on startup. This won't be necessary once JDK 6 support ends\n        // and reflective method handle is not needed.\n        SocketAddressUtils.getHostNameFirst(null);\n    }\n\n    @Override\n    public void start() {\n        synchronized (agentStatusLock) {\n            if (this.agentStatus == AgentStatus.INITIALIZING) {\n                changeStatus(AgentStatus.RUNNING);\n            } else {\n                logger.warn(\"Agent already started.\");\n                return;\n            }\n        }\n\n        logger.info(\"Starting pinpoint Agent.\");\n        this.applicationContext.start();\n        printBanner();\n    }\n\n    private void printBanner() {\n        List<String> dumpKeys = profilerConfig.readList(\"pinpoint.banner.configs\");\n        Mode mode = Mode.valueOf(profilerConfig.readString(\"pinpoint.banner.mode\", \"CONSOLE\").toUpperCase());\n\n        PinpointBanner.Builder builder = PinpointBanner.newBuilder();\n        builder.setBannerMode(mode);\n        builder.setDumpKeys(dumpKeys);\n        builder.setProperties(profilerConfig::readString);\n        builder.setLoggerWriter(logger::info);","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/DefaultAgent.java#L196-L232","documentation":"WARN log from DefaultAgent.start() when the agent is not in the INITIALIZING state, so start() refuses to run and returns immediately. Pinpoint's agent is single-start: once it is RUNNING (or already STOPPED), subsequent start() calls are ignored with this message. The application keeps running; only the profiler lifecycle call is a no-op.","triggerScenarios":"Calling DefaultAgent.start() (or the profiler bootstrap invoking it) twice — e.g. manual start after an automatic start, or a restart attempt after close() when status is STOPPED instead of INITIALIZING.","commonSituations":"Embedding the profiler in an application that calls start() from multiple code paths (Spring bean lifecycle plus manual bootstrap); attempting hot re-attach of the agent after shutdown.","solutions":["Ensure start() is invoked exactly once per agent instance; guard with your own started flag.","Check the agent's current status via getStatus()/AgentStatus before calling start().","If a restart is needed, create a new DefaultAgent instance rather than reusing a STOPPED one.","Trace the caller that double-starts (e.g. duplicate profiler bootstrap on classpath) and remove it."],"exampleFix":"// before\nagent.start();\nschedulerShutdownHook -> agent.start(); // warn: Agent already started.\n\n// after\nif (agent.getStatus() == AgentStatus.INITIALIZING) {\n    agent.start();\n}","handlingStrategy":"type-guard","validationCode":"boolean canStart = (agent.getStatus() == AgentStatus.INITIALIZING);\nif (canStart) agent.start();","typeGuard":"boolean isStartable(DefaultAgent a) { return a.getStatus() == AgentStatus.INITIALIZING; }","tryCatchPattern":"if (agent.getStatus() != AgentStatus.INITIALIZING) {\n    // skip start; log at debug on your side\n} else { agent.start(); }","preventionTips":["Centralize agent start in one bootstrap path.","Guard with an AtomicBoolean started flag around lifecycle calls.","Don't attempt restart on a live agent; construct a new instance instead."],"tags":["lifecycle","double-start","agent"],"backgroundTag":"invalid-state-transition","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"}