From 33e57c408a719d642e66826a5a459ef5e98824b8 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Mon, 22 Feb 2021 12:58:57 +0000 Subject: [PATCH] Removed logging require in `db/connection.js` (#12690) refs https://github.com/TryGhost/Ghost/issues/12496 - having the logging require here means that workers wanting to use the db are unable to do so without requiring logging as a side-effect - `connection.loggingHook` does not appear to be widely used for anything outside of specific debugging scenarios when using MySQL so it should be safe to disable until a proper fix is found for workers+logging leaking file descriptors --- core/server/data/db/connection.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/core/server/data/db/connection.js b/core/server/data/db/connection.js index 8f082486ef..7204424466 100644 --- a/core/server/data/db/connection.js +++ b/core/server/data/db/connection.js @@ -1,7 +1,5 @@ const knex = require('knex'); const config = require('../../../shared/config'); -const logging = require('../../../shared/logging'); -const errors = require('@tryghost/errors'); let knexInstance; // @TODO: @@ -19,12 +17,18 @@ function configure(dbConfig) { dbConfig.connection.timezone = 'UTC'; dbConfig.connection.charset = 'utf8mb4'; - dbConfig.connection.loggingHook = function loggingHook(err) { - logging.error(new errors.InternalServerError({ - code: 'MYSQL_LOGGING_HOOK', - err: err - })); - }; + // NOTE: disabled so that worker processes can use the db without + // requiring logging and causing file desriptor leaks. + // See https://github.com/TryGhost/Ghost/issues/12496 + // + // const logging = require('../../../shared/logging'); + // const errors = require('@tryghost/errors'); + // dbConfig.connection.loggingHook = function loggingHook(err) { + // logging.error(new errors.InternalServerError({ + // code: 'MYSQL_LOGGING_HOOK', + // err: err + // })); + // }; } return dbConfig;