pinpoint-apm/pinpoint · warning

Agent already started.

Error message

Agent already started.

What it means

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.

Solutions

  1. Ensure start() is invoked exactly once per agent instance; guard with your own started flag.
  2. Check the agent's current status via getStatus()/AgentStatus before calling start().
  3. If a restart is needed, create a new DefaultAgent instance rather than reusing a STOPPED one.
  4. Trace the caller that double-starts (e.g. duplicate profiler bootstrap on classpath) and remove it.

Example fix

// before
agent.start();
schedulerShutdownHook -> agent.start(); // warn: Agent already started.

// after
if (agent.getStatus() == AgentStatus.INITIALIZING) {
    agent.start();
}
Defensive patterns

Strategy: type-guard

Validate before calling

boolean canStart = (agent.getStatus() == AgentStatus.INITIALIZING);
if (canStart) agent.start();

Type guard

boolean isStartable(DefaultAgent a) { return a.getStatus() == AgentStatus.INITIALIZING; }

Try / catch

if (agent.getStatus() != AgentStatus.INITIALIZING) {
    // skip start; log at debug on your side
} else { agent.start(); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/DefaultAgent.java:214

            return Paths.get(location);
        }
        return agentPath;
    }


    private void preloadOnStartup() {
        // Preload to fail fast on startup. This won't be necessary once JDK 6 support ends
        // and reflective method handle is not needed.
        SocketAddressUtils.getHostNameFirst(null);
    }

    @Override
    public void start() {
        synchronized (agentStatusLock) {
            if (this.agentStatus == AgentStatus.INITIALIZING) {
                changeStatus(AgentStatus.RUNNING);
            } else {
                logger.warn("Agent already started.");
                return;
            }
        }

        logger.info("Starting pinpoint Agent.");
        this.applicationContext.start();
        printBanner();
    }

    private void printBanner() {
        List<String> dumpKeys = profilerConfig.readList("pinpoint.banner.configs");
        Mode mode = Mode.valueOf(profilerConfig.readString("pinpoint.banner.mode", "CONSOLE").toUpperCase());

        PinpointBanner.Builder builder = PinpointBanner.newBuilder();
        builder.setBannerMode(mode);
        builder.setDumpKeys(dumpKeys);
        builder.setProperties(profilerConfig::readString);
        builder.setLoggerWriter(logger::info);

View on GitHub (pinned to 744c3d3075)