Skip to content

Commit e944603

Browse files
authored
fix: use stop-first update order for all database services (Dokploy#4560)
Docker Swarm's default start-first update order causes new database containers to fail with 'DBPathInUse' because two containers compete for the same data volume simultaneously. Docker then rolls back the update, silently reverting any env var or config changes. Using stop-first ensures the old container is stopped before the new one starts, preventing volume lock conflicts across all database types. Fixes Dokploy#4550
1 parent e6fc3db commit e944603

6 files changed

Lines changed: 30 additions & 6 deletions

File tree

‎packages/server/src/utils/databases/libsql.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ export const buildLibsql = async (libsql: LibsqlNested) => {
140140
: []),
141141
],
142142
},
143-
UpdateConfig,
143+
UpdateConfig: libsql.updateConfigSwarm ?? {
144+
Parallelism: 1,
145+
Order: "stop-first" as const,
146+
FailureAction: "rollback" as const,
147+
},
144148
};
145149
try {
146150
const service = docker.getService(appName);

‎packages/server/src/utils/databases/mariadb.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ export const buildMariadb = async (mariadb: MariadbNested) => {
111111
]
112112
: [],
113113
},
114-
UpdateConfig,
114+
UpdateConfig: mariadb.updateConfigSwarm ?? {
115+
Parallelism: 1,
116+
Order: "stop-first" as const,
117+
FailureAction: "rollback" as const,
118+
},
115119
};
116120
try {
117121
const service = docker.getService(appName);

‎packages/server/src/utils/databases/mongo.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ ${command ?? "wait $MONGOD_PID"}`;
167167
]
168168
: [],
169169
},
170-
UpdateConfig,
170+
UpdateConfig: mongo.updateConfigSwarm ?? {
171+
Parallelism: 1,
172+
Order: "stop-first" as const,
173+
FailureAction: "rollback" as const,
174+
},
171175
};
172176

173177
try {

‎packages/server/src/utils/databases/mysql.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ export const buildMysql = async (mysql: MysqlNested) => {
117117
]
118118
: [],
119119
},
120-
UpdateConfig,
120+
UpdateConfig: mysql.updateConfigSwarm ?? {
121+
Parallelism: 1,
122+
Order: "stop-first" as const,
123+
FailureAction: "rollback" as const,
124+
},
121125
};
122126
try {
123127
const service = docker.getService(appName);

‎packages/server/src/utils/databases/postgres.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ export const buildPostgres = async (postgres: PostgresNested) => {
109109
]
110110
: [],
111111
},
112-
UpdateConfig,
112+
UpdateConfig: postgres.updateConfigSwarm ?? {
113+
Parallelism: 1,
114+
Order: "stop-first" as const,
115+
FailureAction: "rollback" as const,
116+
},
113117
};
114118
try {
115119
const service = docker.getService(appName);

‎packages/server/src/utils/databases/redis.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ export const buildRedis = async (redis: RedisNested) => {
115115
]
116116
: [],
117117
},
118-
UpdateConfig,
118+
UpdateConfig: redis.updateConfigSwarm ?? {
119+
Parallelism: 1,
120+
Order: "stop-first" as const,
121+
FailureAction: "rollback" as const,
122+
},
119123
};
120124

121125
try {

0 commit comments

Comments
 (0)