Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse-server still alive, after I shutdown the http express server. In Unit Test #4343

Closed
trylovetom opened this issue Nov 13, 2017 · 3 comments

Comments

@trylovetom
Copy link
Contributor

trylovetom commented Nov 13, 2017

Issue Description

When I use Jest for unit test, I find some error from my postgres below.

postgres_1  | 2017-11-13 09:50:05.432 UTC [135] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 09:50:05.433 UTC [136] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 09:50:05.434 UTC [137] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 09:50:05.437 UTC [138] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 09:50:05.439 UTC [139] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 09:50:05.440 UTC [140] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 09:50:05.440 UTC [141] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 09:50:05.462 UTC [113] ERROR:  tuple concurrently updated

I have 200 unit test modules. Before each unit test , make the new parse-server. After each unit test, use http-shutdown for force shutdown.
Either mongo or postgres. After each unit testing, it's connection still alive.
I think StorageAdapter not close the connection, after server shutdown.

Lastest Updated

I have rewrote, but it isn't work.
@flovilmart
mongo

After I survey the shutdown code, I found handleShutdown only be implemented in monogo adapter.
It is't work. When I call this handleShutdown function, this.databse get undefined. Because mongo adapter doesn't create a connection yet.

Then, I wait a 3 second, and close it again. It works the mongo db connection!!

mongofix

In postgres adapter I hasn't see it.

My Simply Test Case

import http from 'http'
import express from 'express'
import { ParseServer } from 'parse-server'

const app = express() // create express app
const server = require('http-shutdown')(http.createServer(app)) // use force shutdown
const parseServer = new ParseServer({ // create parse server
  appId: 'Parse',
  databaseURI: 'mongodb://localhost:27017/parse',
  masterKey: 'Key',
  serverURL: 'http://localhost:3000/'
})

app.use('/', parseServer) // mount it

function create () { // listen on 3000 port
  server.listen(3000, () => {
    console.log('Awaken On Port 3000')
    shutdown() // when server on raise, close it
  })
}

function shutdown () {
  server.forceShutdown((err) => { // use force shutdown, it not only close http server also kill the socket connection
    if (err) {
      console.log(err)
    }
    console.log('Closed')
  })
}

create() // start the test

Test Output

Awaken On Port 3000
Closed

WARNING, Unable to connect to 'http://localhost:3000/'. Cloud code and push notifications may be unavailable!

parse-server still alive, after I shutdown the http express server.
Any idea?

Steps to reproduce

one of my unit test code

async function closePYM (server) {
  try {
    await closeAsync(server)
  } catch (err) {
    throw err
  }
  console.info('Your Mom Sleep Again ... zzZ')
}
async function createPYM (config) { // factory mode
  const { logo } = config
  const app = express()
  const parseServer = new ParseServer({
    appId: config.parse.appId,
    databaseURI: config.parse.databaseURI,
    cloud: path.join(__dirname, config.parse.cloud),
    masterKey: config.parse.masterKey,
    serverURL: config.parse.serverURL
  })
  const server = require('http-shutdown')(http.createServer(app))

  app.use(config.parse.mountPath, parseServer)
  app.get('/', (req, res) => {
    res.send(`<pre>${logo}Your Mom Awaken On Port ${config.node.port}</pre>`)
  })

  await listenAsync(server, config.node.port)
  if (config.node.env !== 'test') {
    console.info(`${logo}Your Mom Awaken On Port ${config.node.port}`)
  } else {
    console.info(`Your Mom Awaken On Port ${config.node.port}`)
  }
  return server
}
import { createPYM, closePYM } from '../ParseYourMom'
import supertest from 'supertest'
import config from '../config'

let pym
beforeEach(async () => {
  pym = await createPYM(config)
})

afterEach(async () => {
  await closePYM(pym)
})

test('sayHello', async () => {
  const res = await supertest(pym)
    .post('/v1/functions/hello')
    .set('X-Parse-Application-Id', config.parse.appId)
  expect(res.statusCode).toBe(200)
  expect(res.body).toEqual(expect.any(Object))
  expect(res.body).toEqual(expect.objectContaining({
    result: expect.any(String)
  }))
  expect(res.body.result).toBe('Hi')
})

Expected Results

The DB connection will be close, after each unit testing.

Actual Outcome

The DB connection still alive.

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.6.4
    • Operating System: macOS high sierra
    • Hardware: macbook pro 13
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): localhost
  • Database

    • MongoDB version: 3.4.x and posters 10.0
    • Storage engine:
    • Hardware: same as server
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): localhost

Logs/Trace

mongo

2017-11-13T18:36:18.759+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55009 #16 (1 connection now open)
2017-11-13T18:36:18.767+0800 I NETWORK  [conn16] received client metadata from 127.0.0.1:55009 conn16: { driver: { name: "nodejs", version: "2.2.33" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "17.2.0" }, platform: "Node.js v8.8.1, LE, mongodb-core: 2.1.17" }
2017-11-13T18:36:19.720+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55012 #17 (2 connections now open)
2017-11-13T18:36:19.740+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55013 #18 (3 connections now open)
2017-11-13T18:36:19.741+0800 I NETWORK  [conn17] received client metadata from 127.0.0.1:55012 conn17: { driver: { name: "nodejs", version: "2.2.33" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "17.2.0" }, platform: "Node.js v8.8.1, LE, mongodb-core: 2.1.17" }
2017-11-13T18:36:20.097+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55016 #19 (4 connections now open)
2017-11-13T18:36:20.098+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55017 #20 (5 connections now open)
2017-11-13T18:36:20.104+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55018 #21 (6 connections now open)
2017-11-13T18:36:20.106+0800 I NETWORK  [conn20] received client metadata from 127.0.0.1:55017 conn20: { driver: { name: "nodejs", version: "2.2.33" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "17.2.0" }, platform: "Node.js v8.8.1, LE, mongodb-core: 2.1.17" }
2017-11-13T18:36:20.457+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55021 #22 (7 connections now open)
2017-11-13T18:36:20.457+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55022 #23 (8 connections now open)
2017-11-13T18:36:20.577+0800 I NETWORK  [conn23] received client metadata from 127.0.0.1:55022 conn23: { driver: { name: "nodejs", version: "2.2.33" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "17.2.0" }, platform: "Node.js v8.8.1, LE, mongodb-core: 2.1.17" }
2017-11-13T18:36:20.580+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55023 #24 (9 connections now open)
2017-11-13T18:36:20.866+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55026 #25 (10 connections now open)
2017-11-13T18:36:20.872+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55027 #26 (11 connections now open)
2017-11-13T18:36:20.873+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55028 #27 (12 connections now open)
2017-11-13T18:36:20.874+0800 I NETWORK  [conn25] received client metadata from 127.0.0.1:55026 conn25: { driver: { name: "nodejs", version: "2.2.33" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "17.2.0" }, platform: "Node.js v8.8.1, LE, mongodb-core: 2.1.17" }
2017-11-13T18:36:21.227+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55031 #28 (13 connections now open)
2017-11-13T18:36:21.227+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55032 #29 (14 connections now open)
2017-11-13T18:36:21.233+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55033 #30 (15 connections now open)
2017-11-13T18:36:21.235+0800 I NETWORK  [conn29] received client metadata from 127.0.0.1:55032 conn29: { driver: { name: "nodejs", version: "2.2.33" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "17.2.0" }, platform: "Node.js v8.8.1, LE, mongodb-core: 2.1.17" }
2017-11-13T18:36:21.603+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55036 #31 (16 connections now open)
2017-11-13T18:36:21.604+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55037 #32 (17 connections now open)
2017-11-13T18:36:21.814+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55038 #33 (18 connections now open)
2017-11-13T18:36:21.817+0800 I NETWORK  [conn32] received client metadata from 127.0.0.1:55037 conn32: { driver: { name: "nodejs", version: "2.2.33" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "17.2.0" }, platform: "Node.js v8.8.1, LE, mongodb-core: 2.1.17" }
2017-11-13T18:36:22.614+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55041 #34 (19 connections now open)
2017-11-13T18:36:22.614+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55042 #35 (20 connections now open)
2017-11-13T18:36:22.628+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55043 #36 (21 connections now open)
2017-11-13T18:36:22.631+0800 I NETWORK  [conn35] received client metadata from 127.0.0.1:55042 conn35: { driver: { name: "nodejs", version: "2.2.33" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "17.2.0" }, platform: "Node.js v8.8.1, LE, mongodb-core: 2.1.17" }
2017-11-13T18:36:22.973+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55046 #37 (22 connections now open)
2017-11-13T18:36:22.974+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55047 #38 (23 connections now open)
2017-11-13T18:36:22.980+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55048 #39 (24 connections now open)
2017-11-13T18:36:22.982+0800 I NETWORK  [conn38] received client metadata from 127.0.0.1:55047 conn38: { driver: { name: "nodejs", version: "2.2.33" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "17.2.0" }, platform: "Node.js v8.8.1, LE, mongodb-core: 2.1.17" }
2017-11-13T18:36:23.591+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55051 #40 (25 connections now open)
2017-11-13T18:36:23.592+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55052 #41 (26 connections now open)
2017-11-13T18:36:23.600+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55053 #42 (27 connections now open)
2017-11-13T18:36:23.601+0800 I NETWORK  [conn41] received client metadata from 127.0.0.1:55052 conn41: { driver: { name: "nodejs", version: "2.2.33" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "17.2.0" }, platform: "Node.js v8.8.1, LE, mongodb-core: 2.1.17" }
2017-11-13T18:36:24.193+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55057 #43 (28 connections now open)
2017-11-13T18:36:24.193+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55058 #44 (29 connections now open)
2017-11-13T18:36:24.200+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55059 #45 (30 connections now open)
2017-11-13T18:36:24.203+0800 I NETWORK  [conn44] received client metadata from 127.0.0.1:55058 conn44: { driver: { name: "nodejs", version: "2.2.33" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "17.2.0" }, platform: "Node.js v8.8.1, LE, mongodb-core: 2.1.17" }
2017-11-13T18:36:24.543+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55062 #46 (31 connections now open)
2017-11-13T18:36:24.544+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55063 #47 (32 connections now open)
2017-11-13T18:36:24.549+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55064 #48 (33 connections now open)
2017-11-13T18:36:24.552+0800 I NETWORK  [conn47] received client metadata from 127.0.0.1:55063 conn47: { driver: { name: "nodejs", version: "2.2.33" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "17.2.0" }, platform: "Node.js v8.8.1, LE, mongodb-core: 2.1.17" }
2017-11-13T18:36:24.616+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55066 #49 (34 connections now open)
2017-11-13T18:36:24.949+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55069 #50 (35 connections now open)
2017-11-13T18:36:24.949+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55070 #51 (36 connections now open)
2017-11-13T18:36:24.955+0800 I NETWORK  [conn51] received client metadata from 127.0.0.1:55070 conn51: { driver: { name: "nodejs", version: "2.2.33" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "17.2.0" }, platform: "Node.js v8.8.1, LE, mongodb-core: 2.1.17" }
2017-11-13T18:36:24.959+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:55071 #52 (37 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn48] end connection 127.0.0.1:55064 (37 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn52] end connection 127.0.0.1:55071 (37 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn51] end connection 127.0.0.1:55070 (37 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn50] end connection 127.0.0.1:55069 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn45] end connection 127.0.0.1:55059 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn47] end connection 127.0.0.1:55063 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn44] end connection 127.0.0.1:55058 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn46] end connection 127.0.0.1:55062 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn42] end connection 127.0.0.1:55053 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn43] end connection 127.0.0.1:55057 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn41] end connection 127.0.0.1:55052 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn39] end connection 127.0.0.1:55048 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn36] end connection 127.0.0.1:55043 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn40] end connection 127.0.0.1:55051 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn38] end connection 127.0.0.1:55047 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn37] end connection 127.0.0.1:55046 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn35] end connection 127.0.0.1:55042 (36 connections now open)
2017-11-13T18:36:25.280+0800 I -        [conn33] end connection 127.0.0.1:55038 (36 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn34] end connection 127.0.0.1:55041 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn30] end connection 127.0.0.1:55033 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn32] end connection 127.0.0.1:55037 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn31] end connection 127.0.0.1:55036 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn27] end connection 127.0.0.1:55028 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn26] end connection 127.0.0.1:55027 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn29] end connection 127.0.0.1:55032 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn28] end connection 127.0.0.1:55031 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn25] end connection 127.0.0.1:55026 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn23] end connection 127.0.0.1:55022 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn21] end connection 127.0.0.1:55018 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn22] end connection 127.0.0.1:55021 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn20] end connection 127.0.0.1:55017 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn19] end connection 127.0.0.1:55016 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn17] end connection 127.0.0.1:55012 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn18] end connection 127.0.0.1:55013 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn24] end connection 127.0.0.1:55023 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn16] end connection 127.0.0.1:55009 (35 connections now open)
2017-11-13T18:36:25.281+0800 I -        [conn49] end connection 127.0.0.1:55066 (35 connections now open)

postgres

pym_1       |
pym_1       |     console.info src/ParseYourMom.js:46
pym_1       |       Your Mom Awaken On Port 1337
pym_1       |     console.info src/ParseYourMom.js:57
pym_1       |       Your Mom Sleep Again ... zzZ
pym_1       |
info: Ran cloud function hello for user undefined with:
pym_1       |   Input: {}
pym_1       |   Result: "Hi" functionName=hello, , user=undefined
pym_1       |
pym_1       |  RUNS  ...
postgres_1  | 2017-11-13 10:46:39.456 UTC [89] ERROR:  tuple concurrently updated
postgres_1  | 2017-11-13 10:46:39.456 UTC [89] STATEMENT:  CREATE OR REPLACE FUNCTION json_object_set_key( "json" jsonb, key_to_setTEXT, value_to_set anyelement ) RETURNS jsonb LANGUAGE sql IMMUTABLE STRICT AS $function$ SELECT concat('{', string_agg(to_json("key") || ':' || "value", ','), '}')::jsonb FROM (SELECT * FROM jsonb_each("json") WHERE key <> key_to_set UNION ALL SELECT key_to_set,to_json("value_to_set")::jsonb) AS fields $function$;
(node:15) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 uncaughtException listeners added. Use emitter
.setMaxListeners() to increase limit
(node:15) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 49): TypeError: Cannot read property 'addExpe
ctationResult' of undefined
(node:15) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not
handled will terminate the Node.js process with a non-zero exit code.
 FAIL  src/2Hello/hello.test.js
  ● Console |
pym_1       |
pym_1       |     console.info src/ParseYourMom.js:46
pym_1       |       Your Mom Awaken On Port 1337
pym_1       |     console.info src/ParseYourMom.js:57
pym_1       |       Your Mom Sleep Again ... zzZ
pym_1       |
  ● hello › sayHello
pym_1       |
pym_1       |     error: sorry, too many clients already
pym_1       |
pym_1       |       at Connection.Object.<anonymous>.Connection.parseE (node_modules/pg/lib/connection.js:546:11)
pym_1       |       at Connection.Object.<anonymous>.Connection.parseMessage (node_modules/pg/lib/connection.js:371:19)
pym_1       |       at Socket.<anonymous> (node_modules/pg/lib/connection.js:114:22)
pym_1       |       at emitOne (events.js:115:13)
pym_1       |       at Socket.emit (events.js:210:7)
pym_1       |       at addChunk (_stream_readable.js:263:12)
pym_1       |       at readableAddChunk (_stream_readable.js:250:11)
pym_1       |       at Socket.Readable.push (_stream_readable.js:208:10)
pym_1       |       at TCP.onread (net.js:597:20)
pym_1       |
warn: Unable to ensure uniqueness for user email addresses:  error: sorry, too many clients already
pym_1       |     at Connection.Object.<anonymous>.Connection.parseE (/opt/app/node_modules/pg/lib/connection.js:546:11)
pym_1       |     at Connection.Object.<anonymous>.Connection.parseMessage (/opt/app/node_modules/pg/lib/connection.js:371:19)
pym_1       |     at Socket.<anonymous> (/opt/app/node_modules/pg/lib/connection.js:114:22)
pym_1       |     at emitOne (events.js:115:13)
pym_1       |     at Socket.emit (events.js:210:7)
pym_1       |     at addChunk (_stream_readable.js:263:12)
pym_1       |     at readableAddChunk (_stream_readable.js:250:11)
pym_1       |     at Socket.Readable.push (_stream_readable.js:208:10)
pym_1       |     at TCP.onread (net.js:597:20)
pym_1       |
pym_1       |  RUNS  ...
postgres_1  | 2017-11-13 10:46:40.194 UTC [116] ERROR:  relation "unique_name" already exists
postgres_1  | 2017-11-13 10:46:40.194 UTC [116] STATEMENT:  ALTER TABLE "_Role" ADD CONSTRAINT "unique_name" UNIQUE ("name")
postgres_1  | 2017-11-13 10:46:40.196 UTC [89] ERROR:  current transaction is aborted, commands ignored until end of transaction block
postgres_1  | 2017-11-13 10:46:40.196 UTC [89] STATEMENT:  CREATE OR REPLACE FUNCTION array_add( "array" jsonb, "values" jsonb ) RETURNS jsonb LANGUAGE sql IMMUTABLE STRICT AS $function$ SELECT array_to_json(ARRAY(SELECT unnest(ARRAY(SELECT DISTINCT jsonb_array_elements("array")) || ARRAY(SELECT jsonb_array_elements("values")))))::jsonb; $function$;
postgres_1  | 2017-11-13 10:46:40.197 UTC [129] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 10:46:40.198 UTC [131] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 10:46:40.198 UTC [128] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 10:46:40.199 UTC [130] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 10:46:40.202 UTC [127] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 10:46:40.204 UTC [126] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 10:46:40.205 UTC [125] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 10:46:40.210 UTC [89] ERROR:  current transaction is aborted, commands ignored until end of transaction block
postgres_1  | 2017-11-13 10:46:40.210 UTC [89] STATEMENT:  CREATE OR REPLACE FUNCTION array_add_unique( "array" jsonb, "values" json(node:15) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 uncaughtException listeners added. Use emitter.setMaxListeners() to increase limit
pym_1       |
pym_1       |  RUNS  ...
postgres_1  | 2017-11-13 10:46:40.221 UTC [132] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 10:46:40.222 UTC [133] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 10:46:40.223 UTC [134] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 10:46:40.224 UTC [135] FATAL:  sorry, too many clients already
postgres_1  | 2017-11-13 10:46:40.225 UTC [136] FATAL:  sorry, too many clients already
 FAIL  src/Cloud/cloud.test.js:40.228 UTC [139] FATAL:  sorry, too many clients already
  ● Console |
pym_1       |
pym_1       |     console.info src/ParseYourMom.js:46
pym_1       |       Your Mom Awaken On Port 1337
pym_1       |     console.info src/ParseYourMom.js:57
pym_1       |       Your Mom Sleep Again ... zzZ
pym_1       |
  ● sayHello|
pym_1       |
pym_1       |     error: sorry, too many clients already
pym_1       |
pym_1       |       at Connection.Object.<anonymous>.Connection.parseE (node_modules/pg/lib/connection.js:546:11)
pym_1       |       at Connection.Object.<anonymous>.Connection.parseMessage (node_modules/pg/lib/connection.js:371:19)
pym_1       |       at Socket.<anonymous> (node_modules/pg/lib/connection.js:114:22)
pym_1       |       at emitOne (events.js:115:13)
pym_1       |       at Socket.emit (events.js:210:7)
pym_1       |       at addChunk (_stream_readable.js:263:12)
pym_1       |       at readableAddChunk (_stream_readable.js:250:11)
pym_1       |       at Socket.Readable.push (_stream_readable.js:208:10)
pym_1       |       at TCP.onread (net.js:597:20)
pym_1       |
pym_1       |   ● sayHello
pym_1       |
pym_1       |     error: sorry, too many clients already
pym_1       |
pym_1       |       at Connection.Object.<anonymous>.Connection.parseE (node_modules/pg/lib/connection.js:546:11)
pym_1       |       at Connection.Object.<anonymous>.Connection.parseMessage (node_modules/pg/lib/connection.js:371:19)
pym_1       |       at Socket.<anonymous> (node_modules/pg/lib/connection.js:114:22)
pym_1       |       at emitOne (events.js:115:13)
pym_1       |       at Socket.emit (events.js:210:7)
pym_1       |       at addChunk (_stream_readable.js:263:12)
pym_1       |       at readableAddChunk (_stream_readable.js:250:11)
pym_1       |       at Socket.Readable.push (_stream_readable.js:208:10)
pym_1       |       at TCP.onread (net.js:597:20)
pym_1       |
pym_1       |
pym_1       |  RUNS  ...
postgres_1  | 2017-11-13 10:46:40.232 UTC [138] FATAL:  sorry, too many clients already
(node:15) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 uncaughtException listeners added. Use emitter
.setMaxListeners() to increase limit
warn: Unable to ensure uniqueness for usernames:  error: sorry, too many clients already
pym_1       |     at Connection.Object.<anonymous>.Connection.parseE (/opt/app/node_modules/pg/lib/connection.js:546:11)
pym_1       |     at Connection.Object.<anonymous>.Connection.parseMessage (/opt/app/node_modules/pg/lib/connection.js:371:19)
pym_1       |     at Socket.<anonymous> (/opt/app/node_modules/pg/lib/connection.js:114:22)
pym_1       |     at emitOne (events.js:115:13)
pym_1       |     at Socket.emit (events.js:210:7)
pym_1       |     at addChunk (_stream_readable.js:263:12)
pym_1       |     at readableAddChunk (_stream_readable.js:250:11)
pym_1       |     at Socket.Readable.push (_stream_readable.js:208:10)
pym_1       |     at TCP.onread (net.js:597:20)
pym_1       | warn: Unable to ensure uniqueness for user email addresses:  error: sorry, too many clients already
pym_1       |     at Connection.Object.<anonymous>.Connection.parseE (/opt/app/node_modules/pg/lib/connection.js:546:11)
pym_1       |     at Connection.Object.<anonymous>.Connection.parseMessage (/opt/app/node_modules/pg/lib/connection.js:371:19)
pym_1       |     at Socket.<anonymous> (/opt/app/node_modules/pg/lib/connection.js:114:22)
pym_1       |     at emitOne (events.js:115:13)
pym_1       |     at Socket.emit (events.js:210:7)
pym_1       |     at addChunk (_stream_readable.js:263:12)
pym_1       |     at readableAddChunk (_stream_readable.js:250:11)
pym_1       |     at Socket.Readable.push (_stream_readable.js:208:10)
pym_1       |     at TCP.onread (net.js:597:20)
pym_1       | warn: Unable to ensure uniqueness for role name:  error: sorry, too many clients already
pym_1       |     at Connection.Object.<anonymous>.Connection.parseE (/opt/app/node_modules/pg/lib/connection.js:546:11)
pym_1       |     at Connection.Object.<anonymous>.Connection.parseMessage (/opt/app/node_modules/pg/lib/connection.js:371:19)
pym_1       |     at Socket.<anonymous> (/opt/app/node_modules/pg/lib/connection.js:114:22)
pym_1       |     at emitOne (events.js:115:13)
pym_1       |     at Socket.emit (events.js:210:7)
pym_1       |     at addChunk (_stream_readable.js:263:12)
pym_1       |     at readableAddChunk (_stream_readable.js:250:11)
pym_1       |     at Socket.Readable.push (_stream_readable.js:208:10)
pym_1       |     at TCP.onread (net.js:597:20)
pym_1       |
@trylovetom trylovetom changed the title Need Release DB Connection Pool DB Connection Should Be Closed After Shutdown The Server Nov 14, 2017
@trylovetom trylovetom changed the title DB Connection Should Be Closed After Shutdown The Server parse-erver still alive, after I shutdown the http express server. Nov 14, 2017
@trylovetom trylovetom changed the title parse-erver still alive, after I shutdown the http express server. parse-server still alive, after I shutdown the http express server. Nov 14, 2017
@trylovetom trylovetom changed the title parse-server still alive, after I shutdown the http express server. parse-server still alive, after I shutdown the http express server. Unit Test Nov 14, 2017
@trylovetom
Copy link
Contributor Author

trylovetom commented Nov 14, 2017

Reference #3786, #3718
Use parseServer.handleShutdown()
TypeError: parseServer.handleShutdown is not a function

@trylovetom trylovetom changed the title parse-server still alive, after I shutdown the http express server. Unit Test parse-server still alive, after I shutdown the http express server. In Unit Test Nov 14, 2017
@trylovetom
Copy link
Contributor Author

trylovetom commented Nov 15, 2017

I think we need a function which shutdown the parse itself, express app, and all connections between http server.
And so dose the postgres adapter. #4359, #4352

@trylovetom
Copy link
Contributor Author

trylovetom commented Nov 19, 2017

Use cont = server = ParseServer.start(config) to create a parseServer. Before closed the server, use server.handleShutdown() to close the db connection.
Fix in #4361.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant