Skip to content

Commit

Permalink
Merge branch 'release/2.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Sep 6, 2019
2 parents a268e71 + 24bc77b commit ba26bb4
Show file tree
Hide file tree
Showing 14 changed files with 191 additions and 97 deletions.
62 changes: 30 additions & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,43 +39,41 @@ env:

matrix:
allow_failures:
- node_js: "11"
env: DB=build
- node_js: "12"
env: DB=build SKIP_LEAK=1
include:
- node_js: "11"
env: DB=build
- node_js: "6"
env: DB=mariadb:10.4 SKIP_LEAK=1
- node_js: "12"
env: DB=build SKIP_LEAK=1
- node_js: "8"
env: DB=mariadb:10.4
- node_js: "10"
env: DB=mariadb:10.4
- node_js: "11"
env: DB=mariadb:10.4
- node_js: "11"
env: DB=mariadb:10.4 LINT=1
- node_js: "11"
env: DB=mariadb:10.4 BENCH=1
- node_js: "11"
env: DB=mariadb:10.4 MAXSCALE_VERSION=2.2.9 TEST_PORT=4007 TEST_USER=bob TEXT_DATABASE=test2
- node_js: "11"
env: DB=mariadb:5.5
- node_js: "11"
env: DB=mariadb:10.0
- node_js: "11"
env: DB=mariadb:10.1
- node_js: "11"
env: DB=mariadb:10.2
- node_js: "11"
env: DB=mariadb:10.3
- node_js: "11"
env: DB=mysql:5.5
- node_js: "11"
env: DB=mysql:5.6
- node_js: "11"
env: DB=mysql:5.7
- node_js: "11"
env: DB=mysql:8.0
- node_js: "12"
env: DB=mariadb:10.4 SKIP_LEAK=1
- node_js: "12"
env: DB=mariadb:10.4 LINT=1 SKIP_LEAK=1
- node_js: "12"
env: DB=mariadb:10.4 BENCH=1 SKIP_LEAK=1
- node_js: "12"
env: DB=mariadb:10.4 MAXSCALE_VERSION=2.2.9 TEST_PORT=4007 TEST_USER=bob TEXT_DATABASE=test2 SKIP_LEAK=1
- node_js: "12"
env: DB=mariadb:5.5 SKIP_LEAK=1
- node_js: "12"
env: DB=mariadb:10.0 SKIP_LEAK=1
- node_js: "12"
env: DB=mariadb:10.1 SKIP_LEAK=1
- node_js: "12"
env: DB=mariadb:10.2 SKIP_LEAK=1
- node_js: "12"
env: DB=mariadb:10.3 SKIP_LEAK=1
- node_js: "12"
env: DB=mysql:5.5 SKIP_LEAK=1
- node_js: "12"
env: DB=mysql:5.6 SKIP_LEAK=1
- node_js: "12"
env: DB=mysql:5.7 SKIP_LEAK=1
- node_js: "12"
env: DB=mysql:8.0 SKIP_LEAK=1

notifications:
email: false
Expand Down
29 changes: 16 additions & 13 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ environment:
TEST_LOG_PACKETS: true
matrix:

- DB: '10.4.6'
MEM: "21"
nodejs_version: "6"
SKIP_LEAK: "1"

- DB: '10.4.6'
MEM: "21"
nodejs_version: "8"
Expand All @@ -27,37 +22,45 @@ environment:

- DB: '10.4.6'
MEM: "21"
nodejs_version: "11"
nodejs_version: "12"
SKIP_LEAK: "1"

- DB: '10.4.6'
nodejs_version: "10"
nodejs_version: "12"
MEM: "21"
TEST_ZIP: 1
SKIP_LEAK: "1"

- DB: '10.4.6'
nodejs_version: "10"
nodejs_version: "12"
MEM: "21"
BENCH: "1"
SKIP_LEAK: "1"

- DB: '10.3.16'
MEM: "21"
nodejs_version: "10"
nodejs_version: "12"
SKIP_LEAK: "1"

- DB: '10.2.25'
MEM: "21"
nodejs_version: "10"
nodejs_version: "12"
SKIP_LEAK: "1"

- DB: '10.1.40'
MEM: "21"
nodejs_version: "10"
nodejs_version: "12"
SKIP_LEAK: "1"

- DB: '10.0.38'
MEM: "21"
nodejs_version: "10"
nodejs_version: "12"
SKIP_LEAK: "1"

- DB: '5.5.64'
MEM: "5"
nodejs_version: "10"
nodejs_version: "12"
SKIP_LEAK: "1"

cache:
- node_modules
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarkOne.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const launchBenchs = function(path) {

const test = 'bench_promise_select_one_user.js';
const m = require(path + '/' + test);
bench.initFcts.push(m.initFct);
bench.initFcts.push([m.initFct, m.promise]);
bench.add(m.title, m.displaySql, m.benchFct, m.onComplete, m.promise, m.pool); //, bench.CONN.MYSQL);

bench.suiteReady();
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const launchBenchs = function(path) {
for (let i = 0; i < list.length; i++) {
console.log('benchmark: ./benchs/' + list[i]);
const m = require('./benchs/' + list[i]);
bench.initFcts.push(m.initFct);
bench.initFcts.push([m.initFct, m.promise]);
bench.add(m.title, m.displaySql, m.benchFct, m.onComplete, m.promise, m.pool);
}
bench.suiteReady();
Expand Down
7 changes: 5 additions & 2 deletions benchmarks/common_benchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@ function Bench() {
console.log('start : init test : ' + bench.initFcts.length);
for (let i = 0; i < bench.initFcts.length; i++) {
console.log('initializing test data ' + (i + 1) + '/' + bench.initFcts.length);
if (bench.initFcts[i]) {
bench.initFcts[i].call(this, bench.CONN.MARIADB.drv);
if (bench.initFcts[i][0]) {
bench.initFcts[i][0].call(
this,
bench.initFcts[i][1] ? bench.CONN.PROMISE_MARIADB.drv : bench.CONN.MARIADB.drv
);
}
}
this.currentNb = 0;
Expand Down
9 changes: 9 additions & 0 deletions documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#### 2.1.1 - 06-09-2019

* node.je v12 CI testing
* cluster ordered selector bug fix on failover (thanks to @kkx)
* bump dependencies
* documentation update with node.js v12 minimum TLSv1.2 default support
* connection.reset() error message improvement (and documentation)
* small performance improvement when debug not enable

#### 2.1.0 - 11-07-2019

* [CONJS-19] implement Ed25519 plugin
Expand Down
9 changes: 8 additions & 1 deletion documentation/connection-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@ Hostname/IP doesn't match certificate's altnames: "Host: other.example.com. is n
```
To fix this, correct the `host` value to correspond to the host identified in the certificate.


#### routines:ssl_choose_client_version:unsupported protocol

Since Node.js 12 minimum TLS version is set to 1.2.
MariaDB server can be build with different SSL library, old version supporting only TLS up to 1.1.
The error "1976:error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol" can occur if MariaDB SSL implementation doesn't support TLSv1.2.
This can be solved by :
- Server side: update MariaDB to a recent version
- Client side: permit lesser version with "tls.DEFAULT_MIN_VERSION = 'TLSv1.1';" or with connection configuration: using option `ssl: { secureProtocol: 'TLSv1_1_method' }'


1 change: 1 addition & 0 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ function Connection(options) {
*/
this.debug = val => {
opts.debug = val;
opts.emit('debug', opts.logPackets, opts.debug);
};

this.debugCompress = val => {
Expand Down
24 changes: 22 additions & 2 deletions lib/io/packet-input-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class PacketInputStream {
this.parts = null;
this.partsTotalLen = 0;
this.changeEncoding(this.opts.collation);
this.changeDebug(this.opts.logPackets, this.opts.debug);
this.opts.on('collation', this.changeEncoding.bind(this));
this.opts.on('debug', this.changeDebug.bind(this));
}

changeEncoding(collation) {
Expand All @@ -36,10 +38,17 @@ class PacketInputStream {
: PacketIconvEncoded;
}

receivePacket(packet) {
changeDebug(logPackets, debug) {
this.logPackets = logPackets;
this.debug = debug;
this.receivePacket =
this.logPackets || this.debug ? this.receivePacketDebug : this.receivePacketBasic;
}

receivePacketDebug(packet) {
let cmd = this.currentCmd();

if (packet && (this.opts.logPackets || this.opts.debug)) {
if (packet) {
const packetStr = Utils.log(this.opts, packet.buf, packet.pos, packet.end, this.header);
if (this.opts.logPackets) {
this.info.addPacket(
Expand Down Expand Up @@ -85,6 +94,17 @@ class PacketInputStream {
if (!cmd.onPacketReceive) this.receiveQueue.shift();
}

receivePacketBasic(packet) {
let cmd = this.currentCmd();
if (!cmd) {
this.unexpectedPacket(packet);
return;
}
cmd.sequenceNo = this.header[3];
cmd.onPacketReceive(packet, this.out, this.opts, this.info);
if (!cmd.onPacketReceive) this.receiveQueue.shift();
}

resetHeader() {
this.remainingLen = null;
this.headerLen = 0;
Expand Down
72 changes: 50 additions & 22 deletions lib/io/packet-output-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ class PacketOutputStream {
this.pos = 4;
this.buf = Buffer.allocUnsafe(SMALL_BUFFER_SIZE);
this.changeEncoding(this.opts.collation);
this.changeDebug(this.opts.logPackets, this.opts.debug);

this.opts.on('collation', this.changeEncoding.bind(this));
this.opts.on('debug', this.changeDebug.bind(this));
}

changeEncoding(collation) {
Expand All @@ -47,6 +50,13 @@ class PacketOutputStream {
}
}

changeDebug(logPackets, debug) {
this.logPackets = logPackets;
this.debug = debug;
this.flushBuffer =
this.logPackets || this.debug ? this.flushBufferDebug : this.flushBufferBasic;
}

setStream(stream) {
this.stream = stream;
}
Expand Down Expand Up @@ -381,39 +391,57 @@ class PacketOutputStream {
/**
* Flush the internal buffer.
*/
flushBuffer(commandEnd, remainingLen) {
flushBufferDebug(commandEnd, remainingLen) {
this.buf[0] = this.pos - 4;
this.buf[1] = (this.pos - 4) >>> 8;
this.buf[2] = (this.pos - 4) >>> 16;
this.buf[3] = ++this.cmd.sequenceNo;

this.stream.writeBuf(this.buf.slice(0, this.pos), this.cmd);

if (this.opts.logPackets || this.opts.debug) {
const packet = Utils.log(this.opts, this.buf, 0, this.pos);
if (this.opts.logPackets) {
this.info.addPacket(
'==> conn:' +
(this.info.threadId ? this.info.threadId : -1) +
' ' +
this.cmd.constructor.name +
'(0,' +
this.pos +
')\n' +
packet
);
}
const packet = Utils.log(this.opts, this.buf, 0, this.pos);
if (this.opts.logPackets) {
this.info.addPacket(
'==> conn:' +
(this.info.threadId ? this.info.threadId : -1) +
' ' +
this.cmd.constructor.name +
'(0,' +
this.pos +
')\n' +
packet
);
}

if (this.opts.debug) {
console.log(
'==> conn:%d %s\n%s',
this.info.threadId ? this.info.threadId : -1,
this.cmd.constructor.name + '(0,' + this.pos + ')',
Utils.log(this.opts, this.buf, 0, this.pos)
);
if (this.opts.debug) {
console.log(
'==> conn:%d %s\n%s',
this.info.threadId ? this.info.threadId : -1,
this.cmd.constructor.name + '(0,' + this.pos + ')',
Utils.log(this.opts, this.buf, 0, this.pos)
);
}

if (commandEnd) {
//if last packet fill the max size, must send an empty com to indicate that command end.
if (this.pos === MAX_BUFFER_SIZE) {
this.writeEmptyPacket();
} else {
this.stream.flush(true, this.cmd);
this.buf = Buffer.allocUnsafe(SMALL_BUFFER_SIZE);
}
} else {
this.buf = allocateBuffer(remainingLen + 4);
this.pos = 4;
}
}

flushBufferBasic(commandEnd, remainingLen) {
this.buf[0] = this.pos - 4;
this.buf[1] = (this.pos - 4) >>> 8;
this.buf[2] = (this.pos - 4) >>> 16;
this.buf[3] = ++this.cmd.sequenceNo;
this.stream.writeBuf(this.buf.slice(0, this.pos), this.cmd);
if (commandEnd) {
//if last packet fill the max size, must send an empty com to indicate that command end.
if (this.pos === MAX_BUFFER_SIZE) {
Expand Down
Loading

0 comments on commit ba26bb4

Please sign in to comment.