From db7217ff0dc87602ac2241ea2d931493e16ae13f Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Sun, 1 Jul 2018 00:30:51 +0300 Subject: [PATCH] fix(db): fix connection limitation --- src/background/config.js | 2 +- tests/sphinx.test.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/background/config.js b/src/background/config.js index d676305..0cb3b31 100644 --- a/src/background/config.js +++ b/src/background/config.js @@ -27,7 +27,7 @@ let config = { sphinx: { host : '127.0.0.1', port : 9306, - connectionLimit: 30 + connectionLimit: 12 }, spider: { diff --git a/tests/sphinx.test.js b/tests/sphinx.test.js index f13013f..dfd2cf8 100644 --- a/tests/sphinx.test.js +++ b/tests/sphinx.test.js @@ -2,6 +2,7 @@ import { expect } from "chai"; const mysql = require('mysql') const config = require('../src/background/config') +const {pool} = require('../src/background/mysql') describe("sphinx", () => { let sphinx; @@ -58,4 +59,16 @@ describe("sphinx", () => { done() }) }) + + it("query limit", function(done) { + const sphinx = pool() + let promises = [] + sphinx.query(`delete from feed where id >= 0`, () => { + for(let i = 0; i < 500; i++) + promises.push(sphinx.query(`insert into feed(id, data) values(${i}, 'a')`)) + Promise.all(promises).then(() => { + sphinx.query(`delete from feed where id >= 0`, () => done()) + }) + }) + }) });