Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: /node_modules/ibm_db/build/Release/odbc_bindings.node: ELF file's phentsize not the expected size #968

Closed
kevin-omi opened this issue Dec 3, 2023 · 4 comments

Comments

@kevin-omi
Copy link

Please provide below information while opening an issue to understand your problem

  • Operating System Name where ibm_db is installed: Amazon Linux 2
  • Target Db2 Server Version or output of db2level command from Db2 database system:

For non-Windows system, output of below commands from terminal:

uname
uname -m
node -v
npm ls ibm_db
db2level
echo $IBM_DB_HOME
echo $PATH
echo $LD_LIBRARY_PATH $DYLD_LIBRARY_PATH

node v18.18.2
PATH=/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin
LD_LIBRARY_PATH=/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib

  • Value of any other ibm_db specific environment variable if in use.

LAMBDA_TASK_ROOT=/var/task
NODE_PATH=/opt/nodejs/node12/node_modules/:/opt/nodejs/node_modules:$LAMBDA_RUNTIME_DIR/node_modules:/var/runtime/node_modules:/mnt/efs/node/node_modules

Please provide below problem specific info:

=========================================

I'm having an issue loading the ibm_db module in my AWS Lambda function code. The node_modules is inside the mounted EFS at /mnt/efs/node/node_modules. The node_modules is built from a CI/CD pipeline (Ubuntu linux) and then uploaded to S3 from within the pipeline, and then copied from S3 to EFS via AWS DataSync. The Lambda function is deployed via a custom container using the official base image from https://gallery.ecr.aws/lambda/nodejs using node version 18. I was able to run the application by running the container locally on my computer without any issues.

Dockerfile:

FROM public.ecr.aws/lambda/nodejs:18

ENV NODE_PATH /opt/nodejs/node12/node_modules/:/opt/nodejs/node_modules:$LAMBDA_RUNTIME_DIR/node_modules:/var/runtime/node_modules:/mnt/efs/node/node_modules

RUN yum update -y && yum install make gcc gcc-c++ kernel-devel openssl-devel bzip2-devel python3 -y \
  && yum groupinstall 'Development Tools' -y

COPY index.js package.json ${LAMBDA_TASK_ROOT}

EXPOSE 8080

CMD [ "index.handler" ]

I got the following error message when executing the Lambda function:

{
    "errorType": "Runtime.UnhandledPromiseRejection",
    "errorMessage": "Error: /mnt/efs/node/node_modules/ibm_db/build/Release/odbc_bindings.node: ELF file's phentsize not the expected size",
    "reason": {
        "errorType": "Error",
        "errorMessage": "/mnt/efs/node/node_modules/ibm_db/build/Release/odbc_bindings.node: ELF file's phentsize not the expected size",
        "code": "ERR_DLOPEN_FAILED",
        "stack": [
            "Error: /mnt/efs/node/node_modules/ibm_db/build/Release/odbc_bindings.node: ELF file's phentsize not the expected size",
            "    at Module._extensions..node (node:internal/modules/cjs/loader:1340:18)",
            "    at Module.load (node:internal/modules/cjs/loader:1119:32)",
            "    at Module._load (node:internal/modules/cjs/loader:960:12)",
            "    at Module.require (node:internal/modules/cjs/loader:1143:19)",
            "    at require (node:internal/modules/cjs/helpers:119:18)",
            "    at bindings (/mnt/efs/node/node_modules/bindings/bindings.js:112:48)",
            "    at Object.<anonymous> (/mnt/efs/node/node_modules/ibm_db/lib/odbc.js:57:31)",
            "    at Module._compile (node:internal/modules/cjs/loader:1256:14)",
            "    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)",
            "    at Module.load (node:internal/modules/cjs/loader:1119:32)"
        ]
    },
    "promise": {},
    "stack": [
        "Runtime.UnhandledPromiseRejection: Error: /mnt/efs/node/node_modules/ibm_db/build/Release/odbc_bindings.node: ELF file's phentsize not the expected size",
        "    at process.<anonymous> (file:///var/runtime/index.mjs:1276:17)",
        "    at process.emit (node:events:517:28)",
        "    at emit (node:internal/process/promises:149:20)",
        "    at processPromiseRejections (node:internal/process/promises:283:27)",
        "    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"
    ]
}
@bimalkjha
Copy link
Member

@kevin-omi The error says the processor architecture of system where you installed ibm_db and where you copied are not same. If processor architecture is different, you need to install ibm_db locally. Try below commands:

cd /opt/nodejs/node12/node_modules/ibm_db
npm install

Also, we need complete output of below commands from Amazon Linux 2 system:

uname
uname -m
node -v
npm ls ibm_db
db2level
echo $IBM_DB_HOME
echo $PATH
echo $LD_LIBRARY_PATH $DYLD_LIBRARY_PATH
npm install ibm_db

If you see architecture is arm64, ibm_db will not work as ibm_db is not supported for arm64 architecture. Thanks.

@kevin-omi
Copy link
Author

Linux
x86_64
node v18.18.2
task@ /var/task
└── (empty)
db2level = bash: db2level: command not found
echo $IBM_DB_HOME = blank
PATH=/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin
LD_LIBRARY_PATH=/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib
npm install ibm_db results:
added 48 packages, and audited 49 packages in 19s

3 packages are looking for funding
run npm fund for details

found 0 vulnerabilities
npm notice
npm notice New major version of npm available! 9.8.1 -> 10.2.4
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.2.4
npm notice Run npm install -g npm@10.2.4 to update!
npm notice

The following command is pointless because the ibm_db need write permissions to the license file and other directories, and the Lambda function does not have write permissions to its file system except for the mounted EFS or /tmp folder.

cd /opt/nodejs/node12/node_modules/ibm_db
npm install

@bimalkjha
Copy link
Member

@kevin-omi I suspect the odbc_bindings.node file is getting corrupted when ibm_db get copied from S3 to EFS via AWS DataSync. Please check the transfer mode. If it is not a binary transfer, the binary files will get corrupted.
You may try to install ibm_db under /tmp folder where lambda function has the write permission. Thanks.

@bimalkjha
Copy link
Member

@kevin-omi Let us know if you tried file transfer in binary mode and any update about the issue? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants