snowflakedb / snowflake-connector-nodejs

NodeJS driver
Apache License 2.0
120 stars 124 forks source link

SNOW-752630: by upgrade to 1.6.18: Error: EROFS: read-only file system #432

Closed brianzinn closed 1 year ago

brianzinn commented 1 year ago

Please answer these questions before submitting your issue. Thanks!

  1. What version of NodeJS are you using (node --version and npm --version)? node 16

  2. What operating system and processor architecture are you using? linux (google cloud function)

  3. What are the component versions in the environment (npm list)?

    snow-sheet@1.0.0 D:\github\kitshq-snow-sheet
    ├── @google-cloud/secret-manager@3.5.0
    ├── @types/express@4.17.11
    ├── @types/node@14.14.31
    ├── @types/snowflake-sdk@1.6.12
    ├── @typescript-eslint/eslint-plugin@4.16.1
    ├── @typescript-eslint/parser@4.16.1
    ├── body-parser@1.19.0
    ├── dotenv@8.2.0
    ├── eslint-config-prettier@8.1.0
    ├── eslint@7.21.0
    ├── express@4.17.1
    ├── googleapis@67.1.1
    ├── snowflake-sdk@1.6.18
    └── typescript@4.2.3
  4. What did you do? If possible, provide a recipe for reproducing the error. A complete runnable program is good.

    I have had this code running multiple times daily since March 2021 on 1.6.0, which you are dropping support for in April. This error has not appeared before and does not occur on every call.

import snowflakeSdk from 'snowflake-sdk';

/**
 * 
 * @param snowflakeConnection snowflake SDK connection
 * @param sqlText text to run
 * @param input rows of data for the bulk insert "binds".
 */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const executeQuery = (snowflakeConnection: snowflakeSdk.Connection, sqlText: string, input?: any[][]): Promise<any[]> => {
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  return new Promise<any[]>((resolve, reject) => {
    snowflakeConnection.execute({
      sqlText,
      binds: input,
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      complete: (err: Error, stmt: snowflakeSdk.Statement, rows: any[]) => {
        if (err) {
          reject(err);
          return;
        }
        resolve(rows);
      }
    });
  });
}
  1. What did you expect to see? no errors

  2. What did you see instead?

    Error: EROFS: read-only file system, open '1'
    at Object.openSync (node:fs:590:3)
    at Object.writeFileSync (node:fs:2202:35)
    at BindUploader.UploadStream (/layers/google.nodejs.yarn/yarn_modules/node_modules/snowflake-sdk/lib/connection/bind_uploader.js:111:6)
    at BindUploader.Upload (/layers/google.nodejs.yarn/yarn_modules/node_modules/snowflake-sdk/lib/connection/bind_uploader.js:81:10)
    at Object.exports.createStatementPreExec (/layers/google.nodejs.yarn/yarn_modules/node_modules/snowflake-sdk/lib/connection/statement.js:99:25)
    at Connection.execute (/layers/google.nodejs.yarn/yarn_modules/node_modules/snowflake-sdk/lib/connection/connection.js:325:22)
    at /workspace/dist/snowflake.js:33:29
    at new Promise (<anonymous>)
    at Object.executeQuery (/workspace/dist/snowflake.js:32:12)
  3. Add this to get standard output. n/a

sfc-gh-dszmolka commented 1 year ago

hi, thank you for submitting this issue.

seems to be very likely caused by the bind uploader (introduced in 1.6.14). when the driver inserts data into snowflake with arraybinding, and the bound data exceeds a certain size/amount, it chooses a different ingest strategy. this involves putting temporal files on the filesystem, which when the default current directory is not writable for the driver, is not successful.

as mentioned in https://github.com/snowflakedb/snowflake-connector-nodejs/issues/364#issuecomment-1396820416 (raised for AWS Lambda, should be similar for Google Cloud Function), you can either tackle this by

until the driver is enhanced with a capability to have configureable locations for these temp files. closing this as a duplicate of #364 but if you feel this is an entirely different error, please reopen/comment

brianzinn commented 1 year ago

Thank-you for explanation. I’ll bump the threshold!