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

Eclipse Maven Update "Too Many Files" with 2.7.1 #23655

Closed
jimbogithub opened this issue Feb 14, 2022 · 25 comments
Closed

Eclipse Maven Update "Too Many Files" with 2.7.1 #23655

jimbogithub opened this issue Feb 14, 2022 · 25 comments
Labels
area/maven kind/bug Something isn't working

Comments

@jimbogithub
Copy link

Describe the bug

Upgraded an existing 2.5.1 project to 2.7.1 and then in Eclipse, ran Maven Update. The Maven Update failed with IO errors for "Too Many Files".

On 2.5.1 lsof -p <PID> | wc -l on the Eclipse process shows just over 1,000 open files for my project.
On 2.7.1 it blows through the 10,420 limit and fails. Examining the raw list of files from lsof -p <PID> shows many duplicate references to the same files which does not occur for 2.5.1. Looks like it's loading each dependent jar once for each and every project/module.

Expected behavior

Maven Update should succeed.

Actual behavior

Maven Update fails.

How to Reproduce?

Create a multi-module Maven project.
Import into Eclipse.
Perform "Maven Update" in Eclipse.
Use lsof -p <PID> to observe loaded files.

You may not hit the "Too Many Files" error unless you add enough modules, but you'll still see the increased file count and duplicates versus the 2.5.1 behaviour.

P.S. Can be useful to open Eclipse with the -clean option between tests to ensure there aren't cached files included (mine was showing some 2.7.1 files even after switching back to 2.5.1).

Output of uname -a or ver

Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64

Output of java -version

Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.7.1

Build tool (ie. output of mvnw --version or gradlew --version)

Maven 3.8.4

Additional information

Also tested on non Apple Silicon, same result.

@jimbogithub jimbogithub added the kind/bug Something isn't working label Feb 14, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Feb 14, 2022

/cc @quarkusio/devtools

@geoand
Copy link
Contributor

geoand commented Feb 14, 2022

cc @Postremus @aloubyansky

@jimbogithub
Copy link
Author

FYI, this is still an issue in 2.7.2 and is also not resolved by upgrading the Eclipse EMBEDDED Maven to 3.8.4 (was 3.8.1) which I believe is the one used by Eclipse to resolve dependencies.

@jimbogithub
Copy link
Author

Here are the lists of open files for two different copies of https://github.com/jimbogithub/sse (a reproducer I have for a different issue).

  • With the root pom changed to point to Quarkus 2.5.1: files_2.5.1.txt - Contains 239 matches for quarkus.

  • With the root pom left pointing to Quarkus 2.7.2: files_2.7.2.txt - Contains 1026 matches for quarkus.

Both lists obtained from distinct newly created Eclipse Workspaces.

@jimbogithub
Copy link
Author

2.6.3 does not have this issue.

@Postremus Postremus self-assigned this Feb 27, 2022
@famod
Copy link
Member

famod commented Feb 27, 2022

@Postremus FWIW, jars are loaded multiple times in that 2.7.2 dump, e.g.:

  • jackson-annotations-2.13.1.jar 7 times
  • maven-core 8 times

Those are loaded at most 2 times in the 2.5.1 dump.

But you probably already noticed that.

@gsmet
Copy link
Member

gsmet commented Feb 28, 2022

This is concerning. @Postremus do you think you will have the time to look at it before tomorrow evening? If not, we will need to have someone else having a look.

@Postremus
Copy link
Member

Postremus commented Feb 28, 2022

@gsmet My plan was to start looking at this issue in detail today. But I honestly don't think that I am able to fix this in todays remaining 3 hours.
I will dig into this a bit though.

Yesterday, I did some tests with only quarkus-fs-util, found nothing so far. Calling close() on the opened fs correctly closes the ZipFileSystem. The FileSystem path itself is also not locked, i.e. I can rename the zip file.

@Postremus Postremus removed their assignment Feb 28, 2022
@Postremus
Copy link
Member

Postremus commented Feb 28, 2022

I guess I figured it out.

During a "Maven Update" in eclipse, the following goals are invoked:

  • generate-code
  • generate-code-tests

The generate-code goal uses a QuarkusClassLoader (the dev mode classloader), which internally opens a lot of OpenArchivePathTree instances.
This kind of Tree keeps the backing FileSystem open, until an explicit close invoked.

This never happens though during this goal invocation.

For cli uses, this does not matter, the whole maven process shuts down at the end of execution, and all locks are freed.
In eclipse however, the Mojo instance is kept by m2e for the runtime of eclipse, meaning no OpenArchivePathTree`s will ever be closed.

This is at only my first assumption at this point. I am unable to confirm this as the root cause, since my fedora installation is out of order.

Let me prepare a fix though, which someone on linux can verify.

/cc @gsmet @aloubyansky

@jimbogithub
Copy link
Author

Nice work. 2.7.3 is now showing a little over half the files open that even 2.5.1 had. Thanks.

@aloubyansky
Copy link
Member

Great! Thanks for checking @jimbogithub

@jimbogithub
Copy link
Author

@aloubyansky Same problem is occurring when building (mvn clean install). More mojos impacted? Raise another issue or re-open this one?

@aloubyansky
Copy link
Member

mvn clean install on the Quarkus repo? From an IDE?

@jimbogithub
Copy link
Author

mvn clean install on the Quarkus repo? From an IDE?

On the command line whilst building multiple Quarkus based apps as part of a multi-module build.
In fact, the exact same set of projects as the original issue.
I didn't notice earlier as I didn't hit the open file limit but a colleague had more things already running on his machine and hit the limit.
Running lsof | grep java > open_files.txt during the build shows the same symptoms, i.e. multiple copies of jars with 2.7.x, far fewer files with 2.5.x.

@aloubyansky
Copy link
Member

@jimbogithub would you be able to build Quarkus from a custom branch and test it in your builds?

@jimbogithub
Copy link
Author

@jimbogithub would you be able to build Quarkus from a custom branch and test it in your builds?

Yes I could.

@aloubyansky
Copy link
Member

@jimbogithub before I ask you to give it a try, do you need generate-code/generate-code-tests goals in your builds? Are they present in your configs? E.g. do you have the gRPC extension in your apps?
If you don't need them, you could try removing them and see whether it makes a significant difference. If it's troublesome, I'll create a branch with an optimization/cleanup for those goals that you could try.

@gsmet
Copy link
Member

gsmet commented Mar 8, 2022

These goals are in the default generated project. So we will need them to work OK.

@aloubyansky
Copy link
Member

Absolutely. It's just before asking @jimbogithub to build the thing and test it I thought we could try to narrow down the issue.

@jimbogithub
Copy link
Author

We do have generate-code/generate-code-tests for the reasons @gsmet points out but we don't use gRPC so if that means we can remove them then I could try that on our main build.

In the meantime I've added two branches to the https://github.com/jimbogithub/sse reproducer from earlier on. The with_sleep branch simply sleeps for 30 seconds (via a test) at the end of the build so that you have time to capture the list of open files. The with_sleep_no_generate branch removes the generate-code/generate-code-tests goals as you suggested and does appear to significantly close the gap in the number of open files. You can tweak the version in the root pom to see the differences.

@jimbogithub
Copy link
Author

Removed generate-code/generate-code-tests from our main build. That appears to resolve the issue. Running while true; do lsof | grep java | wc -l && echo "" && sleep 2; done at the same time as the build showed a background count of about 300 (no build running), peaks of around 2000 when running QuarkusTests, troughs of around 700 while compiling. No obvious sign of leakage except that the troughs did bump up to around 980 towards the end of the build, but possibly due to the later modules having some extra/different libraries.

Without those removed the counts go into the many 1,000s.

Can I safely leave those out then? I always thought they were mandatory.

@aloubyansky
Copy link
Member

#24173 should help then. Hopefully it'll make it in 2.7.4.Final scheduled to be released tomorrow.
AFAIR, only the gRPC extension relies on the generate-code goals. Kogito extensions also had plans for them. Otherwise, they aren't required.

@aloubyansky
Copy link
Member

Thanks a lot for testing @jimbogithub

@famod
Copy link
Member

famod commented Mar 8, 2022

@aloubyansky maybe those mojos should log something as INFO if they are not needed.

@aloubyansky
Copy link
Member

I am not sure about that, tbh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/maven kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants