Skip to content

Database connection timeouts after some time and strapi crashed #8436

@sarsonj

Description

@sarsonj

Bug report

Describe the bug

I am using Strapi as dockerised app inside Caprover PAAS. What happens is that when some time of inactivity, the app crashed in the next request. It looks like that connection to database is terminated.

This happens with both mysql and posgresql backend.

The strapi crashes then.

Steps to reproduce the behavior

  1. install strapi as dockerized app into Caprover PAAS
  2. use one-click mysql or pgsql app

Logs:

2020-10-22T11:20:22.986874066Z [2020-10-22T11:20:22.986Z] debug GET /blog-articles?_start=0&_limit=5&_sort=Date:DESC&IsPublished=true (23 ms) 200
2020-10-22T11:20:23.181097954Z [2020-10-22T11:20:23.180Z] debug GET /blog-articles/count?IsPublished=true (15 ms) 200
2020-10-22T11:46:05.945389043Z [2020-10-22T11:46:05.945Z] error Error: read ECONNRESET
2020-10-22T11:46:05.945432223Z     at TCP.onStreamRead (internal/stream_base_commons.js:208:20)
2020-10-22T11:46:05.945438229Z     --------------------
2020-10-22T11:46:05.945442289Z     at Protocol._enqueue (/src/app/node_modules/mysql/lib/protocol/Protocol.js:145:48)
2020-10-22T11:46:05.945446377Z     at Connection.query (/src/app/node_modules/mysql/lib/Connection.js:208:25)
2020-10-22T11:46:05.945450155Z     at /src/app/node_modules/knex/lib/dialects/mysql/index.js:135:18
2020-10-22T11:46:05.945453786Z     at new Promise (<anonymous>)
2020-10-22T11:46:05.945458024Z     at Client_MySQL._query (/src/app/node_modules/knex/lib/dialects/mysql/index.js:129:12)
2020-10-22T11:46:05.945461647Z     at Client_MySQL.query (/src/app/node_modules/knex/lib/client.js:169:17)
2020-10-22T11:46:05.945465213Z     at Runner.query (/src/app/node_modules/knex/lib/runner.js:151:36)
2020-10-22T11:46:05.945468775Z     at /src/app/node_modules/knex/lib/runner.js:40:23
2020-10-22T11:46:05.945472593Z     at /src/app/node_modules/knex/lib/runner.js:277:24
2020-10-22T11:46:05.946054687Z [2020-10-22T11:46:05.945Z] debug GET /blog-articles?_start=0&_limit=5&_sort=Date:DESC&IsPublished=true (7 ms) 500
2020-10-22T11:48:21.500096306Z [2020-10-22T11:48:21.499Z] error Error: read ECONNRESET
2020-10-22T11:48:21.500134178Z     at TCP.onStreamRead (internal/stream_base_commons.js:208:20)
2020-10-22T11:48:21.500139415Z     --------------------
2020-10-22T11:48:21.500143792Z     at Protocol._enqueue (/src/app/node_modules/mysql/lib/protocol/Protocol.js:145:48)
2020-10-22T11:48:21.500149650Z     at Connection.query (/src/app/node_modules/mysql/lib/Connection.js:208:25)
2020-10-22T11:48:21.500153608Z     at /src/app/node_modules/knex/lib/dialects/mysql/index.js:135:18
2020-10-22T11:48:21.500164357Z     at new Promise (<anonymous>)
2020-10-22T11:48:21.500168736Z     at Client_MySQL._query (/src/app/node_modules/knex/lib/dialects/mysql/index.js:129:12)
2020-10-22T11:48:21.500172376Z     at Client_MySQL.query (/src/app/node_modules/knex/lib/client.js:169:17)
2020-10-22T11:48:21.500176009Z     at Runner.query (/src/app/node_modules/knex/lib/runner.js:151:36)
2020-10-22T11:48:21.500179811Z     at /src/app/node_modules/knex/lib/runner.js:40:23
2020-10-22T11:48:21.500183483Z     at /src/app/node_modules/knex/lib/runner.js:277:24

System

  • Node.js version: 12 LTS
  • NPM version:
  • Strapi version: 3.2.4
  • Database: mysql or pgsql
  • Operating system: docker - using node:lts-alpine

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugIssue reporting a bugseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solvesource: core:databaseSource is core/database packagesource: docsDocumentation changesstatus: confirmedConfirmed by a Strapi Team member or multiple community members

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions