awslabs / aws-elasticache-cluster-client-memcached-for-php

Amazon ElastiCache Cluster Client is an enhanced PHP library to connect to ElastiCache clusters. This client library has been built upon libmemcached and is released under the Apache License.
Other
62 stars 33 forks source link

Unable to use latest client file: Unable to load dynamic library '/usr/local/lib/php/extensions/amazon-elasticache-cluster-client.so' #54

Open pauljura opened 3 months ago

pauljura commented 3 months ago

I have a Docker image for a legacy application running PHP 8.2 with the AWS Elasticache Cluster client.

When I tried rebuilding it today, it is no longer able to load the amazon-elasticache-cluster-client.so extension.

If I copy the amazon-elasticache-cluster-client.so file out of my existing container (dated March 1, 2023) my new image will run perfectly fine. But if I download and extract the latest one (file is dated Nov 11, 2023) I get the following error:

Warning: PHP Startup: Unable to load dynamic library 'amazon-elasticache-cluster-client.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20220829/amazon-elasticache-cluster-client.so (/usr/local/lib/php/extensions/no-debug-non-zts-20220829/amazon-elasticache-cluster-client.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20220829/amazon-elasticache-cluster-client.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20220829/amazon-elasticache-cluster-client.so.so: cannot open shared object file: No such file or directory)) in Unknown on line
0

To prove the only difference is the extension, I have both extension files saved side by side and I can build 2 images with literally the only difference being which file gets included. The older one works, the newer one causes an error.

# using the old file works:
COPY amazon-elasticache-cluster-client-2023-03.so /usr/local/lib/php/extensions/amazon-elasticache-cluster-client.so
# using newer file gives an error
COPY amazon-elasticache-cluster-client-2023-11.so /usr/local/lib/php/extensions/amazon-elasticache-cluster-client.so

Something has changed, maybe there is a new dependency I'm not aware of, maybe there is a thread-safe vs. non-thread-safe mixup, I don't know. But definitely the latest file does not work for me.

Ordinarily this wouldn't be a problem, I could just keep the old file and never update it. But I'm trying to migrate this legacy app from an AMD EC2 to a new ARM64 EC2, and so I'm downloading the ARM64 client, and building my image from scratch, so now I'm getting that error. And I don't have a copy of the old client that was built for ARM64 (I didn't need it before).

What can I do? Am I missing some dependency? Can I download an older version of the extension? The download page in AWS always gives me the latest.

Thanks in advance for any help.

pauljura commented 2 months ago

Output of running ldd with the old extension:

ldd /usr/local/lib/php/extensions/amazon-elasticache-cluster-client.so
        linux-vdso.so.1 (0x00007ffe027cc000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd09c21b000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd09c001000)
        libssl.so.3 => /lib/x86_64-linux-gnu/libssl.so.3 (0x00007fd09bf58000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd09bf38000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd09bd57000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd09bc76000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fd09c293000)
        libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007fd09b7f3000)

with the newer extension:

ldd /usr/local/lib/php/extensions/amazon-elasticache-cluster-client.so
        linux-vdso.so.1 (0x00007ffcf04e7000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f6e1dd50000)
        libcrypt.so.2 => not found
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6e1dc71000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f6e1da57000)
        libssl.so.3 => /lib/x86_64-linux-gnu/libssl.so.3 (0x00007f6e1d9ae000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f6e1d98c000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6e1d7ab000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f6e1ddc3000)
        libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007f6e1d328000)

Looks like libcrypt.so.2 is a new dependency and is missing. Trying to figure out how to install this now...

pauljura commented 2 months ago

I couldn't figure out where to get the libcrypt.so.2 from so I just made the following symlink:

For AMD: ln -s /lib/x86_64-linux-gnu/libcrypto.so.3 /lib/x86_64-linux-gnu/libcrypt.so.2

For ARM: ln -s /lib/aarch64-linux-gnu/libcrypto.so.3 /lib/aarch64-linux-gnu/libcrypt.so.2

It seems to work. I'm not sure if this is a good thing to do, but I haven't run into any problems yet.