oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.39k stars 1.64k forks source link

installing Graal.js language component via gu fails with error "org.graalvm.component.installer.FailedOperationException: Component metadata storage is corrupted." #7951

Open ispringer opened 11 months ago

ispringer commented 11 months ago

Describe the issue I have GraalVM CE 22.3.3 installed on an Amazon Linux 1 box:

$ uname -a Linux t5a1 4.14.252-131.483.amzn1.x86_64 #1 SMP Mon Nov 1 20:48:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ java -version openjdk version "11.0.20" 2023-07-18 OpenJDK Runtime Environment GraalVM CE 22.3.3 (build 11.0.20+8-jvmci-22.3-b22) OpenJDK 64-Bit Server VM GraalVM CE 22.3.3 (build 11.0.20+8-jvmci-22.3-b22, mixed mode, sharing)

When I try to install Graal.js via gu, it fails with:

Installation of Graal.js failed: Component metadata storage is corrupted.
org.graalvm.component.installer.FailedOperationException: Component metadata storage is corrupted.
    at org.graalvm.component.installer.Environment.failure(Environment.java:214)

Steps to reproduce the issue Please include both build steps as well as run steps

  1. install GraalVM CE 22.3.3
  2. sudo /usr/lib/jvm/java/bin/gu -e install js

Fails as follows:

$ sudo /usr/lib/jvm/java/bin/gu -e install js
Downloading: Component catalog from www.graalvm.org
Processing Component: Graal.js
Downloading: Component js: Graal.js from github.com
Installing new component: Graal.js (org.graalvm.js, version 22.3.3)
Installation of Graal.js failed: Component metadata storage is corrupted.
org.graalvm.component.installer.FailedOperationException: Component metadata storage is corrupted.
    at org.graalvm.component.installer.Environment.failure(Environment.java:214)
    at org.graalvm.component.installer.persist.DirectoryStorage.getRequiredProperty(DirectoryStorage.java:487)
    at org.graalvm.component.installer.persist.DirectoryStorage.loadMetadataFrom(DirectoryStorage.java:304)
    at org.graalvm.component.installer.persist.DirectoryStorage.doLoadComponentMetadata(DirectoryStorage.java:447)
    at org.graalvm.component.installer.persist.DirectoryStorage.loadComponentMetadata(DirectoryStorage.java:442)
    at org.graalvm.component.installer.model.ComponentRegistry.loadSingleComponent(ComponentRegistry.java:374)
    at org.graalvm.component.installer.model.ComponentRegistry.loadSingleComponent(ComponentRegistry.java:350)
    at org.graalvm.component.installer.model.ComponentRegistry.loadAllComponents(ComponentRegistry.java:341)
    at org.graalvm.component.installer.model.ComponentRegistry.buildFileIndex(ComponentRegistry.java:403)
    at org.graalvm.component.installer.model.ComponentRegistry.getComponentDirectories(ComponentRegistry.java:434)
    at org.graalvm.component.installer.commands.InstallCommand.doInstallation(InstallCommand.java:675)
    at org.graalvm.component.installer.commands.InstallCommand.executeStep(InstallCommand.java:565)
    at org.graalvm.component.installer.commands.InstallCommand.execute(InstallCommand.java:206)
    at org.graalvm.component.installer.ComponentInstaller.doProcessCommand(ComponentInstaller.java:447)
    at org.graalvm.component.installer.ComponentInstaller.processCommand(ComponentInstaller.java:461)
    at org.graalvm.component.installer.ComponentInstaller.run(ComponentInstaller.java:580)
    at org.graalvm.component.installer.ComponentInstaller.main(ComponentInstaller.java:633)
Error: Component metadata storage is corrupted.
org.graalvm.component.installer.FailedOperationException: Component metadata storage is corrupted.
    at org.graalvm.component.installer.Environment.failure(Environment.java:214)
    at org.graalvm.component.installer.persist.DirectoryStorage.getRequiredProperty(DirectoryStorage.java:487)
    at org.graalvm.component.installer.persist.DirectoryStorage.loadMetadataFrom(DirectoryStorage.java:304)
    at org.graalvm.component.installer.persist.DirectoryStorage.doLoadComponentMetadata(DirectoryStorage.java:447)
    at org.graalvm.component.installer.persist.DirectoryStorage.loadComponentMetadata(DirectoryStorage.java:442)
    at org.graalvm.component.installer.model.ComponentRegistry.loadSingleComponent(ComponentRegistry.java:374)
    at org.graalvm.component.installer.model.ComponentRegistry.loadSingleComponent(ComponentRegistry.java:350)
    at org.graalvm.component.installer.model.ComponentRegistry.loadAllComponents(ComponentRegistry.java:341)
    at org.graalvm.component.installer.model.ComponentRegistry.buildFileIndex(ComponentRegistry.java:403)
    at org.graalvm.component.installer.model.ComponentRegistry.getComponentDirectories(ComponentRegistry.java:434)
    at org.graalvm.component.installer.commands.InstallCommand.doInstallation(InstallCommand.java:675)
    at org.graalvm.component.installer.commands.InstallCommand.executeStep(InstallCommand.java:565)
    at org.graalvm.component.installer.commands.InstallCommand.execute(InstallCommand.java:206)
    at org.graalvm.component.installer.ComponentInstaller.doProcessCommand(ComponentInstaller.java:447)
    at org.graalvm.component.installer.ComponentInstaller.processCommand(ComponentInstaller.java:461)
    at org.graalvm.component.installer.ComponentInstaller.run(ComponentInstaller.java:580)
    at org.graalvm.component.installer.ComponentInstaller.main(ComponentInstaller.java:633)

Describe GraalVM and your environment:

More details

Looking at the source code for the DirectoryStorage class, it looks like this is the line that fails:

https://github.com/oracle/graal/blob/master/vm/src/org.graalvm.component.installer/src/org/graalvm/component/installer/persist/DirectoryStorage.java#L304

It's trying to read the "Bundle-Symbolic-Name" prop from the component metadata for the graaljs bundle and not finding it.

But i cracked open the jar and that prop does appear to be set...

$ more lib/installer/components/org.graalvm.js.component
Bundle-Name=Graal.js
Bundle-Symbolic-Name=org.graalvm.js
Bundle-Version=22.3.3
Bundle-RequireCapability=org.graalvm; filter\:\="(&(graalvm_version\=22.3.3)(os_name\=linux)(os_arch\=amd64)(java_version\=11))"
x-GraalVM-Stability-Level=supported
x-GraalVM-Stability=supported
x-GraalVM-Working-Directories=languages/js
x-GraalVM-Component-Distribution=bundled
$ more lib/installer/components/org.graalvm.component
Bundle-Name=GraalVM Core
Bundle-Symbolic-Name=org.graalvm
Bundle-Version=22.3.3
x-GraalVM-Stability-Level=supported
alina-yur commented 11 months ago

hi @ispringer! we tried to reproduce this locally and the installation was successful. Can you please try the following and tell us if it worked?

$ curl -LO https://github.com/oracle/graaljs/releases/download/vm-22.3.3/js-installable-svm-java11-linux-amd64-22.3.3.jar
$ ./bin/gu install --file js-installable-svm-java11-linux-amd64-22.3.3.jar

Also do you know if this happens as well in other environments?

ispringer commented 9 months ago

Hi @alina-yur, same issue:

$ curl -LOs https://github.com/oracle/graaljs/releases/download/vm-22.3.3/js-installable-svm-java11-linux-amd64-22.3.3.jar
$ sudo ${JAVA_HOME}/bin/gu install --file js-installable-svm-java11-linux-amd64-22.3.3.jar
Processing Component archive: /home/ec2-user/js-installable-svm-java11-linux-amd64-22.3.3.jar
Installing new component: Graal.js (org.graalvm.js, version 22.3.3)
Installation of Graal.js failed: Component metadata storage is corrupted.
Error: Component metadata storage is corrupted.

The only other platform I have tried it on is OS X aarch64, and it was not an issue there.

ansalond commented 9 months ago

Hi @ispringer! I'm sorry, I can't reproduce the issue:

$ mkdir test
$ cd test
$ curl -LO https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.3/graalvm-ce-java11-linux-amd64-22.3.3.tar.gz
$ curl -LO https://github.com/oracle/graaljs/releases/download/vm-22.3.3/js-installable-svm-java11-linux-amd64-22.3.3.jar
$ tar xzf graalvm-ce-java11-linux-amd64-22.3.3.tar.gz
$ ./graalvm-ce-java11-22.3.3/bin/gu install --file js-installable-svm-java11-linux-amd64-22.3.3.jar
Processing Component archive: js-installable-svm-java11-linux-amd64-22.3.3.jar
Installing new component: Graal.js (org.graalvm.js, version 22.3.3)

For reference:

$ sha1sum graalvm-ce-java11-linux-amd64-22.3.3.tar.gz
b083c780d01b6343470612a9f06c72606c30a528  graalvm-ce-java11-linux-amd64-22.3.3.tar.gz
$ sha1sum js-installable-svm-java11-linux-amd64-22.3.3.jar
01556abf98112cc54746550659311929efd3c1fe  js-installable-svm-java11-linux-amd64-22.3.3.jar
ispringer commented 9 months ago

Hi @ansalond, your test case worked for me.

The js-installable jar I was originally using was identical to yours, so I figured it must be something different about the GraalVM install dir. And I recalled that I did repackage the tar.gz file in order to change the top-level install directory name to something that would be compatible with the java chef cookbook, which we use to install GraalVM.

So I thought the "corrupt metadata storage" error message might be referring to the metadata under ${JAVA_HOME}/lib/installer/components and not the metadata within the js-installable jar as I originally thought. And sure enough, there were two suspicious hidden files in that dir:

cd /usr/lib/jvm/graalvm-ce-java11-linux-amd64-22.3.3/lib/installer/components
$ ls -al
total 24K
drwxr-xr-x 3 root root 4.0K Feb  2 22:21 .
drwxr-xr-x 4 root root 4.0K Feb  2 22:21 ..
-rw-r--r-- 1 root root  163 Jul 20  2023 ._org.graalvm.component
-rw-r--r-- 1 root root  116 Jul 20  2023 org.graalvm.component
drwxr-xr-x 2 root root 4.0K Dec  4 23:00 polyglot
-rwxr-xr-x 1 root root  163 Dec  4 23:00 ._polyglot
$ file ._org.graalvm.component
._org.graalvm.component: AppleDouble encoded Macintosh file
$ file ._polyglot
._polyglot: AppleDouble encoded Macintosh file

Deleting these two files solved the issue!

$ sudo rm -f ._*
$ sudo ${JAVA_HOME}/bin/gu install --file /opt/evergage/installs/js-installable-svm-java11-linux-amd64-22.3.3.jar
Processing Component archive: /opt/evergage/installs/js-installable-svm-java11-linux-amd64-22.3.3.jar
Installing new component: Graal.js (org.graalvm.js, version 22.3.3)

It turns out Mac OS X creates these ._ hidden files all over the place, and when I retarred the GraalVM install, they got included... Apparently I could have excluded those files by passing the --no-mac-metadata option to OS X tar. In any case, next time, I'll just do my re-tarring on Linux.

Sorry for the false alarm! Thanks for your diligence in trying to reproduce! I hope this issue will at least help some other people out in the future who encounter this issue or a similar issue.

ansalond commented 9 months ago

Thank you @ispringer for the feedback!

Indeed, gu assumes that all .component files in lib/installer/components have a specific format.

Since GraalVM 23.1, gu is not included in GraalVM releases anymore, but we might want to push to active release branches a fix that skips files that start with ..