dokploy icon indicating copy to clipboard operation
dokploy copied to clipboard

Main Server Error Error: (HTTP code 409) unexpected - rpc error

Open gentslava opened this issue 10 months ago • 1 comments

To Reproduce

  1. Reboot working server
  2. Get error Main Server Error Error: (HTTP code 409) unexpected - rpc error: code = AlreadyExists desc = name conflicts with an existing object: service dokploy-postgres already exists

Current vs. Expected behavior

Expected behavior: The server restarts without errors.

Current behavior: Instead, the server crashes with an error, and I have to delete all services and create a new one.

Provide environment information

Operating System:
  OS: Linux Armbian v25.2.0 for Odroid N2
  Kernel: 6.1.127-ophub
  Arch: aarch64
Dokploy version: v0.17.9
VPS Provider: Own server

Which area(s) are affected? (Select all that apply)

Application

Are you deploying the applications where Dokploy is installed or on a remote server?

Same server where Dokploy is installed

Additional context

root@armbian:~# docker ps
CONTAINER ID   IMAGE                                                       COMMAND                  CREATED              STATUS              PORTS                                                                      NAMES
90274a0b010c   redis:7                                                     "docker-entrypoint.s…"   58 seconds ago       Up 55 seconds       6379/tcp                                                                   dokploy-redis.1.jo09elldhtrgjh3zf3drgl5bi
7dba5c3b8b49   postgres:16                                                 "docker-entrypoint.s…"   58 seconds ago       Up 54 seconds       5432/tcp                                                                   dokploy-postgres.1.3wk6slkhshabapy3er9y1zwuj
9d518e3f8302   traefik:v3.1.2                                              "/entrypoint.sh trae…"   58 seconds ago       Up 55 seconds       0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   dokploy-traefik.1.qfw8eyvcy1y9g1y5abv7xcgpb
ddaad54bab86   dokploy/dokploy:latest                                      "docker-entrypoint.s…"   About a minute ago   Up 54 seconds       0.0.0.0:3000->3000/tcp, :::3000->3000/tcp                                  dokploy.1.po3574ea8klrosy1g4kv32t17
root@armbian:~# docker logs dokploy.1.po3574ea8klrosy1g4kv32t17

> [email protected] start /app
> node -r dotenv/config dist/server.mjs

Default middlewares already exists
Network is already initilized
Main config already exists
Default traefik config already exists
Main Server Error Error: (HTTP code 409) unexpected - rpc error: code = AlreadyExists desc = name conflicts with an existing object: service dokploy-postgres already exists
    at /app/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:382:17
    at getCause (/app/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:417:7)
    at Modem.buildPayload (/app/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:378:5)
    at IncomingMessage.<anonymous> (/app/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:346:16)
    at IncomingMessage.emit (node:events:530:35)
    at endReadableNT (node:internal/streams/readable:1698:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  reason: undefined,
  statusCode: 409,
  json: {
    message: 'rpc error: code = AlreadyExists desc = name conflicts with an existing object: service dokploy-postgres already exists'
  }
}

Image

Will you send a PR to fix it?

Maybe, need help

gentslava avatar Feb 01 '25 05:02 gentslava

Image

error potentially happened at https://github.com/Dokploy/dokploy/blob/97b77e526d439404ae63ff129a7b66c3b0c994eb/packages/server/src/setup/postgres-setup.ts#L49

means pull image failed (loss or weak network) then create duplicated service failed.

maybe better error msg

Soontao avatar Feb 04 '25 03:02 Soontao

You are right, this looks like a race condition, which surely when the server restarts and dokploy starts it doesn't detect the service so it tries to recreate it however that service already exists just when dokploy tries to recreate it, I added a validation for that error specifically to handle the exception, I hope it gets fixed!

Siumauricio avatar Feb 15 '25 20:02 Siumauricio