fix(db): fix connection limitation

This commit is contained in:
Alexey Kasyanchuk 2018-07-01 00:30:51 +03:00
parent 070119c352
commit db7217ff0d
2 changed files with 14 additions and 1 deletions

View File

@ -27,7 +27,7 @@ let config = {
sphinx: { sphinx: {
host : '127.0.0.1', host : '127.0.0.1',
port : 9306, port : 9306,
connectionLimit: 30 connectionLimit: 12
}, },
spider: { spider: {

View File

@ -2,6 +2,7 @@ import { expect } from "chai";
const mysql = require('mysql') const mysql = require('mysql')
const config = require('../src/background/config') const config = require('../src/background/config')
const {pool} = require('../src/background/mysql')
describe("sphinx", () => { describe("sphinx", () => {
let sphinx; let sphinx;
@ -58,4 +59,16 @@ describe("sphinx", () => {
done() 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())
})
})
})
}); });