Skip to content

Commit 378aaea

Browse files
SNOW-1215393: Test chunk fetching causing out of memory
1 parent 983b623 commit 378aaea

File tree

6 files changed

+35
-10
lines changed

6 files changed

+35
-10
lines changed

ci/container/test_component.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
77
export WORKSPACE=${WORKSPACE:-/mnt/workspace}
88
export SOURCE_ROOT=${SOURCE_ROOT:-/mnt/host}
99
export DRIVER_NAME=nodejs
10-
export TIMEOUT=180000
10+
export TIMEOUT=360000
1111
export SF_OCSP_TEST_OCSP_RESPONDER_TIMEOUT=1000
1212

1313
[[ -z "$GIT_BRANCH" ]] && echo "Set GIT_BRANCH to test" && exit 1
@@ -70,11 +70,11 @@ python3 $THIS_DIR/hang_webserver.py 12345 > hang_webserver.out 2>&1 &
7070
if [[ "$SHOULD_GENERATE_COVERAGE_REPORT" == "1" ]];
7171
then
7272
MOCHA_CMD=(
73-
"npx" "nyc" "--reporter=lcov" "--reporter=text" "mocha" "--exit" "--timeout" "$TIMEOUT" "--recursive" "--full-trace"
73+
"npx" "nyc" "--reporter=lcov" "--reporter=text" "mocha" "--exit" "--timeout" "$TIMEOUT" "--recursive" "--full-trace" "--max-old-space-size=150"
7474
)
7575
else
7676
MOCHA_CMD=(
77-
"mocha" "--timeout" "$TIMEOUT" "--recursive" "--full-trace"
77+
"mocha" "--timeout" "$TIMEOUT" "--recursive" "--full-trace" "--max-old-space-size=150"
7878
)
7979
fi
8080

lib/connection/result/chunk.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ Chunk.prototype.clearRows = function (force) {
160160
// clear out all row and rowset related fields
161161
this._rowsetAsString = this._rowset = this._rows = undefined;
162162
}
163+
this._isProcessed = true;
164+
console.log(`Cleared chunk ${this._id}`);
163165
};
164166

165167
/**
@@ -199,6 +201,16 @@ Chunk.prototype.isLoading = function () {
199201
* @param callback
200202
*/
201203
Chunk.prototype.load = function (callback) {
204+
// if (this.isLoaded()) {
205+
// console.log(`Ordered fetch of chunk ${this._id} when is already loaded - skipping`);
206+
// return;
207+
// }
208+
if (this._isProcessed) {
209+
console.log(`Ordered fetch of chunk ${this._id} when is already processed`);
210+
}
211+
if (this.isLoaded()) {
212+
console.log(`Ordered fetch of chunk ${this._id} when is already loaded`);
213+
}
202214
// we've started loading
203215
this._isLoading = true;
204216

@@ -237,6 +249,7 @@ Chunk.prototype.load = function (callback) {
237249
// if the request succeeded, save the
238250
// body as a string version of the rowset
239251
if (!err) {
252+
console.log(`Fetched chunk ${self._id}`);
240253
self._rowsetAsString = body;
241254
}
242255

@@ -257,7 +270,7 @@ Chunk.prototype.load = function (callback) {
257270
* @private
258271
*/
259272
function buildId(startIndex, endIndex) {
260-
return Util.format('s=%d, e=%d', startIndex, endIndex);
273+
return Util.format('s=%d, e=%d size=%d', startIndex, endIndex, endIndex - startIndex + 1);
261274
}
262275

263276
/**

lib/connection/result/result_stream.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function ResultStream(options) {
8484
for (index = currChunk; index < chunks.length && index <= (currChunk + prefetchSize); index++) {
8585
chunk = chunks[index];
8686
if (!chunk.isLoading()) {
87+
console.log(`Fetching chunk ${chunk._id}`);
8788
chunk.load();
8889
}
8990
}

lib/connection/result/row_stream.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ function RowStream(statement, context, options) {
196196
rowBuffer = chunk.getRows().slice(
197197
Math.max(chunkStart, start) - chunkStart,
198198
Math.min(chunkEnd, end) + 1 - chunkStart);
199+
console.log(`Row buffer length is ${rowBuffer.length}` );
199200

200201
// reset the row index
201202
rowIndex = 0;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"lint:check:all:errorsOnly": "npm run lint:check:all -- --quiet",
6262
"lint:fix": "eslint --fix",
6363
"test": "mocha -timeout 180000 --recursive --full-trace test/unit/**/*.js test/unit/*.js",
64-
"test:integration": "mocha -timeout 180000 --recursive --full-trace test/integration/**/*.js test/integration/*.js",
64+
"test:integration": "mocha -timeout 360000 --recursive --full-trace test/integration/**/*.js test/integration/*.js",
6565
"test:single": "mocha -timeout 180000 --full-trace",
6666
"test:system": "mocha -timeout 180000 --recursive --full-trace system_test/*.js",
6767
"test:unit": "mocha -timeout 180000 --recursive --full-trace test/unit/**/*.js test/unit/*.js",

test/integration/testLargeResultSet.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,41 @@ const assert = require('assert');
55
const async = require('async');
66
const testUtil = require('./testUtil');
77
const { randomizeName } = require('./testUtil');
8+
const { writeHeapSnapshot } = require('node:v8');
89

910
describe('Large result Set Tests', function () {
10-
const sourceRowCount = 10000;
11-
11+
const sourceRowCount = 1000000;
1212
let connection;
1313
const selectAllFromOrders = `select randstr(1000,random()) from table(generator(rowcount=>${sourceRowCount}))`;
14-
14+
// const selectAllFromOrders = `select * from fake_sample_data.public.customer limit 400000`;
15+
// const selectAllFromOrders = `select * from fake_sample_data.public.customer`;
1516
before(async () => {
16-
connection = testUtil.createConnection();
17+
// configureLogger('TRACE');
18+
connection = testUtil.createConnection({
19+
resultPrefetch: 2,
20+
});
1721
await testUtil.connectAsync(connection);
22+
await testUtil.executeCmdAsync(connection, "alter session set CLIENT_RESULT_CHUNK_SIZE=48");
1823
});
1924

2025
after(async () => {
2126
await testUtil.destroyConnectionAsync(connection);
2227
});
2328

24-
it('testSimpleLarge', function (done) {
29+
it.only('testSimpleLarge', function (done) {
2530
connection.execute({
2631
sqlText: selectAllFromOrders,
32+
streamResult: true,
2733
complete: function (err, stmt) {
2834
testUtil.checkError(err);
2935
const stream = stmt.streamRows();
3036
let rowCount = 0;
3137
stream.on('data', function () {
3238
rowCount++;
39+
if (rowCount % 5000 === 0) {
40+
console.log(`Row count: ${rowCount}`);
41+
// console.log(writeHeapSnapshot());
42+
}
3343
});
3444
stream.on('error', function (err) {
3545
testUtil.checkError(err);

0 commit comments

Comments
 (0)