Constraints:
- Node – v18.14.2
- MongoDB Server – v7.0.11
- Mongoose – Migrating from v6.12.6 to v7.6.13 [OR v7.7.0]
The problem at hand is bumping mongoose version is leading to unexpected behaviour of resource consumption + retrieval when the container containing the backend service is spun up.
As soon as the container is spun up (via docker) the consumption of CPU spikes to max and comes down a minute or two later, however there is no operation being performed at this stage which should lead to this.
After that, the DB queries do not yield any results.
Here’s what I tried
- Awaiting MongoDB connection to be established and blocking flow before this is accomplished.
- Bumped the other mongo related packages we use
- connect-mongo – v5.0.0 -> v5.0.1
- mongoose-delete – v0.5.4 -> v1.0.0
- mongoose-delete – v2.2.1
- mongoose-delete – v0.9.1
- Made sure everything is aligned with this migration guide
Interesting fact is that the retrieval failure happens only when the container is spun up on ECS via a task. (We use Fargate for this)
The following error is scene on ECS logs:
However, the health checks continue to respond with 200 so the tasks remains up all the time.
Dockerfile:
FROM node:18
WORKDIR /albus
COPY package*.json ./
COPY ./node_modules ./node_modules # We do npm install while creating artifact on Azure so no requirement of running npm install here
COPY . .
EXPOSE 3000
CMD ["npm", "start"]