Skip to content

Commit 23bdb22

Browse files
authored
Merge pull request #12 from revolut-engineering/dpl-267-fix-broken-fetches
Fix large fetches, switch away from batch execution
2 parents a259fe1 + b2e1af3 commit 23bdb22

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
4+
## 0.0.7
5+
6+
Fix websocket max message size leading to broken fetches
7+
Switch away from batch mode
8+
Always show full schema
9+
Fix issue with global connection state
10+
311
## 0.0.6
412

513
Fix pagination, fetch up to 1000 records from queries

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "exasol-driver",
33
"displayName": "Exasol Driver",
44
"description": "Exasol Driver for SQLTools",
5-
"version": "0.0.6",
5+
"version": "0.0.7",
66
"engines": {
77
"vscode": "^1.42.0"
88
},

src/ls/driver.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { zipObject, range, Dictionary } from 'lodash';
99
import Exasol from './wsjsapi';
1010
import keywordsCompletion from './keywords';
1111
import LRUCache from 'lru-cache';
12+
import { IClientConfig } from 'websocket';
1213

1314
// DriverLib type is any since the connection object obtained from Exasol is a plain JS object
1415
type DriverLib = any;
@@ -43,7 +44,7 @@ type QueryFetchResult = {
4344
}
4445

4546
const MAX_RESULTS = 1000 // rows
46-
const FETCH_SIZE = 1000000 // 1MiB (bytes)
47+
const FETCH_SIZE = 4 * 1024 * 1024 // 4MB (bytes)
4748
const QUERY_CACHE_SIZE = 100 // queries count
4849
const QUERY_CACHE_AGE = 1000 * 60 * 10 // 10 minutes (ms)
4950

@@ -73,7 +74,8 @@ export default class ExasolDriver extends AbstractDriver<DriverLib, DriverOption
7374
Exasol.call({}, // we must pass a new thisArg object each time as connection state is kept there and we might spawn multiple connections
7475
`ws://${this.credentials.server}:${this.credentials.port}`, this.credentials.username, this.credentials.password,
7576
resolve,
76-
this.rejectErr(reject))
77+
this.rejectErr(reject),
78+
<IClientConfig>{ maxReceivedFrameSize: 2 * FETCH_SIZE })
7779
).then(db =>
7880
new Promise((resolve, reject) =>
7981
db.com({
@@ -111,20 +113,20 @@ export default class ExasolDriver extends AbstractDriver<DriverLib, DriverOption
111113
const db = await this.open();
112114
const splitQueries = parse(queries);
113115

114-
const responseData: QueryResponse = await this.queue.add(
115-
() => new Promise(
116-
(resolve, reject) => db.com({ 'command': 'executeBatch', 'sqlTexts': splitQueries },
117-
resolve,
118-
this.rejectErr(reject))
119-
)
120-
);
121-
const res = [];
122-
for (let index = 0; index < responseData.results.length; index++) {
123-
const result = responseData.results[index];
116+
const responses: QueryResponse[] = await Promise.all<QueryResponse>(
117+
splitQueries.map((query) => this.queue.add(() =>
118+
new Promise((resolve, reject) =>
119+
db.com({ 'command': 'execute', 'sqlText': query }, resolve, this.rejectErr(reject))
120+
)
121+
)));
122+
123+
const res: NSDatabase.IResult[] = [];
124+
for (let index = 0; index < responses.length; index++) {
125+
const result = responses[index].results[0];
124126
if (result.resultType === 'rowCount') {
125127
const message = `Query ok with ${result.rowCount} rows affected`
126128
this.log.info(message)
127-
res.push(<NSDatabase.IResult>{
129+
res.push({
128130
cols: [],
129131
connId: this.getId(),
130132
messages: [{ date: new Date(), message: message }],

src/ls/wsjsapi.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ var json_parse = (function () {
302302
};
303303
}());
304304

305-
var Exasol = function(url, user, pass, onconnect, onerror) {
305+
var Exasol = function(url, user, pass, onconnect, onerror, websocketConfig) {
306306
var context = this;
307307
context.onerror = onerror;
308308
context.sessionId = "-1";
@@ -489,7 +489,7 @@ var Exasol = function(url, user, pass, onconnect, onerror) {
489489
};
490490

491491
context.inwork = false;
492-
context.connection = new WebSocket(url);
492+
context.connection = new WebSocket(url, null, null, null, null, websocketConfig);
493493
context.connection.onerror = function(err) {
494494
onerror('Error connecting to "' + url + '"');
495495
};

0 commit comments

Comments
 (0)