umzug.up() unstable and throwing ECONNRESET when used in Kubernetes Pod container
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- node.js, postgresql, typescript
Research direction
The relevant entry points are src/db/db.ts, src/db/config.ts, and src/db/migrate.ts; start by running node ./src/db/migrate.js with the same Kubernetes and PostgreSQL settings. Compare behavior with and without the shown pool configuration and use the reported ECONNRESET as the failure signal. Done should be a reproducible cause and a documented fix or confirmed container guidance.
Written by the indexing model from the issue text.
Description
I'm using Umzug migrations in an app that is deployed to the Kubernetes cluster. There is where I first run the migrations upon the start of the container, before I actually start the app. The migration (or it's connection to the database) is at this point is very unstable. It sometimes (rarely though) works properly right after the deployment, the other times I need to restart the Deployment (Pods) several times and eventually it does connect to the database and executes the migrations.
If I execute the migrations from the same app, but from local computer, the migrations always get executed flawlessly, so it cannot be up to the database that this issues arise.
Mostly I have notice that the migrations are working the worst from a container when I set my own database pool configuration, but also with that I could not pinpoint the problem.
Are there any particular considerations when using the Umzug for migrations in a container?
Umzug version: v3.8.2
Storage: SequelizeStorage
Database: Postgres
Sequelize version: v6.37.7
Node version: v22
Dev setup: Typescript, but it's transpiled to vanilla commonjs when deployed
Execution: "node ./src/db/migrate.js"
My code:
// ./src/db/db.ts
import { DataTypes, Transaction } from "sequelize";
import { Model, Sequelize } from "sequelize-typescript";
import { Umzug, SequelizeStorage } from "umzug";
import * as clsHooked from "cls-hooked";
import { config } from "./config";
// Model for instantiating Sequelize
import { Address, Condition, Document, Header, Partner, Position } from "../models";
export const cls = clsHooked.createNamespace("cls-namespace");
// Only do this if using PostgreSQL
if (config.dialect === "postgres") {
// @ts-expect-error-next-line
DataTypes.postgres.DECIMAL.parse = function (value: string) {
return Number(value);
};
}
Sequelize.useCLS(cls);
const { database, username, password, ...dbConfig } = config;
export const sql = new Sequelize(database, username, password, {
...dbConfig,
models: [Address, Partner, Header, Position, Condition, Document],
});
export const migrator = new Umzug({
migrations: {
glob: ["./migrations/*.{ts,js}", { cwd: __dirname }],
},
context: sql.getQueryInterface(),
storage: new SequelizeStorage({
sequelize: sql,
modelName: "x_migrator_meta",
}),
logger: console,
});
// ./src/db/config.ts
import { SequelizeOptions } from "sequelize-typescript";
// import * as env from "../env";
export const config = {
username: process.env.DB_USER || "postgres",
password: process.env.DB_PASSWORD || "supersecret",
database: process.env.DB_NAME || "postgres",
host: process.env.DB_HOST || "localhost",
port: Number(process.env.DB_PORT) || 5432,
dialect: "postgres" as SequelizeOptions["dialect"],
dialectOptions: {
ssl: Boolean(process.env.SSL_MODE === "true" || process.env.SSL_MODE === "require"),
useNativeUUID: true,
},
// pool: {
// min: Number(env.get("DB_POOL_MIN_CONNECTIONS")),
// max: Number(env.get("DB_POOL_MAX_CONNECTIONS")),
// acquire: Number(env.get("DB_POOL_ACQUIRE_IN_MS")),
// idle: Number(env.get("DB_POOL_IDLE_IN_MS")),
// },
logging: process.env.DB_VERBOSE === "true",
minifyAliases: true,
migrationStorageTableSchema: "sales_orders",
schema: "sales_orders",
};
// ./src/db/migrate.ts
import { migrator } from "./db";
migrator.runAsCLI().finally(() => process.exit(0)); // process.exit(0) because otherwise it exits with code 1 when error occurs
- Dominant language
- TypeScript
- Stars
- 2.2k
- Forks
- 162
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sequelize/umzug
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Security Vulnerability: ajv (JSON Schema Validator)Possibly taken @claabs claimed this 238 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 40/100
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
lichess-org/lila#22324 · 1 comment ·
Maintainers usually reply within 1 day
-
[Feature Request] [Web] Expose kvCacheQuantizationBits in the onnxruntime-web WebGPU EP optionsOpenep:WebGPU platform:web quantization
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
microsoft/onnxruntime#33752 ·
Maintainers usually reply within 2 days
-
[Skill Bug]: entra-agent-id: inaccurate blueprint permission inheritance and parent token sub claimOpenbug entra-agent-id
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/GitHub-Copilot-for-Azure#3467 · 1 comment ·
Maintainers usually reply within 1 day
-
fix(worker): keep normal prepare waiting states failure-freePossibly taken @LichKing-2234 claimed this today. Openagent:codex priority:P1
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
AgoraIO-Extensions/agent-infra#3745 ·
Maintainers usually reply within 1 day
-
The five-line work window can drop its oldest line: the per-line byte share ignores the JSON framingPossibly taken @Eapp1e claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
makecindy/cindy#7973 · 1 comment ·
Maintainers usually reply within 1 day