Skip to content

Include jvmkill in Docker image#13736

Merged
electrum merged 2 commits intotrinodb:masterfrom
electrum:jvmkill
Aug 19, 2022
Merged

Include jvmkill in Docker image#13736
electrum merged 2 commits intotrinodb:masterfrom
electrum:jvmkill

Conversation

@electrum
Copy link
Copy Markdown
Member

@electrum electrum commented Aug 18, 2022

Description

Include the jvmkill agent to ensure the JVM is terminated on any resource exhaustion event, such as unable to create a native thread. This is important, because various code such as BoundedExecutor can become unusable after this occurs.

Documentation

(x) No documentation is needed.

Release notes

(x) Release notes entries required with the following suggested text:

# Docker image
* Terminate the JVM if unable to create a native thread. ({issue}`13736`)

@cla-bot cla-bot bot added the cla-signed label Aug 18, 2022
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we compile from source I believe it would work on all 3 of x64, arm64 and ppcle64 arches?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that’s why I did it this way. I wish there was an easier way to package this so we don’t need to build every time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could add a workflow in the jvmkill repo that would create releases with binaries for different architectures.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing is ok for me. Also serves as an example for others who want to add similar in their own docker images.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nineinchnick I like that idea. Then we could just download them from the GitHub releases URL?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for teaching that we can have un-named stages (numbered starting from 0).

Suggested change
COPY --chown=trino:trino --from=0 /tmp/jvmkill/libjvmkill.so /usr/lib/trino/bin
COPY --chown=trino:trino --from=builder /tmp/jvmkill/libjvmkill.so /usr/lib/trino/bin

Then change L14 to be FROM eclipse-temurin:17-jdk AS builder. More idiomatic and familiar to most people AFAIK.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, that's definitely easier to understand. The --from=0 makes me think it's reading from stdin. I had copied that from some other Dockerfile.

@hashhar
Copy link
Copy Markdown
Member

hashhar commented Aug 18, 2022

A question and two nits.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we pin this to some commit? I expect jvmkill to rarely change but still it would prevent accidentally breaking workflows here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jvmkill has been stable since its initial commit in 2015, so pointing to master seems good, since the only changes are bug fixes (like adding _exit() as an alternative way to die). I do like your idea of doing releases through GHA, then we could point to an exact release.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much larger does this make the image? We shouldn't keep these tools beyond what's needed to build the image.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a separate builder image. We just copy the (tiny) library into the final image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants