Skip to content

Commit d33fcfc

Browse files
committed
Merge branch 'release/v5.2.0'
2 parents 62fb620 + e33226c commit d33fcfc

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,9 @@ from MySQL to PostgreSQL as easy and smooth as possible.</p>
8787
<b>Note:</b> "logs_directory" will be created during script execution.</p>
8888

8989
<h3>VERSION</h3>
90-
<p>Current version is 5.1.0<br />
90+
<p>Current version is 5.2.0<br />
9191
(major version . improvements . bug fixes)</p>
9292

93-
<h3>KNOWN ISSUES</h3>
94-
<ul>
95-
<li>Empty strings in char/varchar columns may be interpreted as NULL.</li>
96-
</ul>
97-
9893
<h3>LICENSE</h3>
9994
<p>NMIG is available under "GNU GENERAL PUBLIC LICENSE" (v. 3) <br />
10095
<a href="http://www.gnu.org/licenses/gpl.txt">http://www.gnu.org/licenses/gpl.txt.</a></p>

config/config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151
],
5252
"loader_max_old_space_size" : "DEFAULT",
5353

54+
"streams_high_water_mark_description": [
55+
"Buffer level when stream.write() starts returning false.",
56+
"This number is a number of JavaScript objects."
57+
],
58+
"streams_high_water_mark": 16384,
59+
5460
"encoding_description" : [
5561
"JavaScript encoding type.",
5662
"If not supplied, then utf8 will be used as a default."

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nmig",
3-
"version": "5.1.0",
3+
"version": "5.2.0",
44
"description": "The database migration app",
55
"author": "Anatoly Khaytovich<anatolyuss@gmail.com>",
66
"license": "GPL-3.0",

src/Conversion.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ export default class Conversion {
190190
*/
191191
public _dataTypesMap: any;
192192

193+
/**
194+
* Buffer level when stream.write() starts returning false.
195+
* This number is a number of JavaScript objects.
196+
*/
197+
public readonly _streamsHighWaterMark: number;
198+
193199
/**
194200
* Constructor.
195201
*/
@@ -215,6 +221,8 @@ export default class Conversion {
215221
this._dataPool = [];
216222
this._dicTables = Object.create(null);
217223
this._mySqlDbName = this._sourceConString.database;
224+
this._streamsHighWaterMark = this._config.streams_high_water_mark === undefined ? 16384 : +this._config.streams_high_water_mark;
225+
218226
this._schema = this._config.schema === undefined || this._config.schema === ''
219227
? this._mySqlDbName
220228
: this._config.schema;

src/DataLoader.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,15 @@ async function populateTableWorker(
136136
originalSessionReplicationRole
137137
);
138138

139-
const streamsHighWaterMark: number = 16384; // Commonly used as the default, but may vary across different machines.
140-
const json2csvStream = await getJson2csvStream(conv, originalTableName, streamsHighWaterMark, dataPoolId, client, originalSessionReplicationRole);
139+
const json2csvStream = await getJson2csvStream(conv, originalTableName, dataPoolId, client, originalSessionReplicationRole);
141140
const mysqlClientErrorHandler = async (err: string) => {
142141
await processDataError(conv, err, sql, sqlCopy, tableName, dataPoolId, client, originalSessionReplicationRole);
143142
};
144143

145144
mysqlClient
146145
.query(sql)
147146
.on('error', mysqlClientErrorHandler)
148-
.stream({ highWaterMark: streamsHighWaterMark })
147+
.stream({ highWaterMark: conv._streamsHighWaterMark })
149148
.pipe(json2csvStream)
150149
.pipe(copyStream);
151150
}
@@ -186,7 +185,6 @@ function getCopyStream(
186185
async function getJson2csvStream(
187186
conversion: Conversion,
188187
originalTableName: string,
189-
streamsHighWaterMark: number,
190188
dataPoolId: number,
191189
client: PoolClient,
192190
originalSessionReplicationRole: string | null
@@ -208,13 +206,13 @@ async function getJson2csvStream(
208206
fields: tableColumnsResult.data.map((column: any) => column.Field)
209207
};
210208

211-
const transformOptions: any = {
212-
highWaterMark: streamsHighWaterMark,
209+
const streamTransformOptions: any = {
210+
highWaterMark: conversion._streamsHighWaterMark,
213211
objectMode: true,
214212
encoding: conversion._encoding
215213
};
216214

217-
const json2CsvTransformStream = new Json2CsvTransform(options, transformOptions);
215+
const json2CsvTransformStream = new Json2CsvTransform(options, streamTransformOptions);
218216

219217
json2CsvTransformStream.on('error', async (transformError: string) => {
220218
await processDataError(conversion, transformError, '', '', originalTableName, dataPoolId, client, originalSessionReplicationRole);

0 commit comments

Comments
 (0)