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()) + }) + }) + }) });