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

fix: -XX:HeapDumpPath doesn't ready when meet OOM #5157

Merged
merged 2 commits into from
Jun 14, 2024

Conversation

Anilople
Copy link
Contributor

@Anilople Anilople commented Jun 11, 2024

What's the purpose of this PR

fix scripts/startup.sh

Which issue(s) this PR fixes:

Brief changelog

When meet OOM, the .hprof file should auto dump,
but the directory not ready, so meet some error.

This pr prepare the directory for OOM when startup.

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Read the Contributing Guide before making this pull request.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit tests to verify the code.
  • Run mvn clean test to make sure this pull request doesn't break anything.
  • Update the CHANGES log.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where -XX:HeapDumpPath was not ready when encountering an OutOfMemory error.
  • Chores

    • Updated startup scripts to create a HeapDumpOnOutOfMemoryError directory under the existing log directory.

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 11, 2024
Copy link

coderabbitai bot commented Jun 11, 2024

Walkthrough

In version 2.3.0 of Apollo, a fix was introduced to ensure the -XX:HeapDumpPath is ready when encountering an OutOfMemory error. This involved updating startup scripts across various services to create a necessary directory under the $LOG_DIR.

Changes

Files/Paths Change Summary
CHANGES.md Added a summary of the fix for -XX:HeapDumpPath readiness on OutOfMemory error.
apollo-adminservice/src/main/scripts/startup.sh, apollo-configservice/src/main/scripts/startup.sh, apollo-portal/src/main/scripts/startup.sh Added commands to create HeapDumpOnOutOfMemoryError directory under $LOG_DIR in startup scripts.

Poem

In Apollo's code, a change so bright,
To handle memory's darkest night.
Directories made with scripts so neat,
Ensuring dumps land on their feet.
Version two-three-oh, we cheer,
For smoother runs, no need to fear.
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Anilople Anilople added area/configservice apollo-configservice area/portal apollo-portal area/adminservice apollo-adminservice and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jun 11, 2024
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 11, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 11, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (14)
CHANGES.md (2)

Line range hint 1-1: Ensure headings are surrounded by blank lines for proper markdown formatting.

+ 
Changes by Version
==================
Release Notes.
+

Line range hint 8-8: Ensure lists are surrounded by blank lines for proper markdown formatting.

+
* [Fix circular references on LdapAutoConfiguration](https://github.com/apolloconfig/apollo/pull/5055)
* [Add comment for clusters and UI display](https://github.com/apolloconfig/apollo/pull/5072)
* [Fix the issue that the length of private namespaces are mis-calculated](https://github.com/apolloconfig/apollo/pull/5078)
* [apollo assembly optimization](https://github.com/apolloconfig/apollo/pull/5035)
* [update the config item table column width](https://github.com/apolloconfig/apollo/pull/5131)
* [sync apollo portal server config to apollo quick start server](https://github.com/apolloconfig/apollo/pull/5134)
* [Fix the role permission deletion issue when appid contains '_'](https://github.com/apolloconfig/apollo/pull/5150)
* [fix: -XX:HeapDumpPath doesn't ready when meet OOM](https://github.com/apolloconfig/apollo/pull/5157)
+
apollo-portal/src/main/scripts/startup.sh (4)

Line range hint 55-55: Replace iterating over ls output with globs to avoid issues with filenames containing spaces or special characters.

- for i in `ls $SERVICE_NAME-*.jar 2>/dev/null`
+ for i in $SERVICE_NAME-*.jar

Also applies to: 136-136, 147-147


Line range hint 90-90: Ensure variables and commands are properly quoted to prevent word splitting and globbing issues.

- if [ "$(uname)" == "Darwin" ]; then
+ if [ "$(uname)" == "Darwin" ] || [ "$(uname)" == "Linux" ]; then

Also applies to: 92-92, 134-134, 146-146


Line range hint 101-101: Declare and assign separately to avoid masking return values.

- declare -i counter=0
+ declare -i counter
+ counter=0

[!TIP]
Codebase Verification

The result variable is assigned a value but is not used elsewhere in the script. Consider removing it to clean up the code.

  • Line 59: result=$(ps -p "$pid")
Analysis chain

Line range hint 59-59: Verify the usage of the result variable or consider removing it if it's not used.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check if the `result` variable is used elsewhere in the script.

rg --type bash 'result' apollo-portal/src/main/scripts/startup.sh

Length of output: 94



Script:

#!/bin/bash
# Description: Check if the `result` variable is used elsewhere in the script.

rg --type sh 'result' apollo-portal/src/main/scripts/startup.sh

Length of output: 94

apollo-adminservice/src/main/scripts/startup.sh (4)

Line range hint 55-55: Replace iterating over ls output with globs to avoid issues with filenames containing spaces or special characters.

- for i in `ls $SERVICE_NAME-*.jar 2>/dev/null`
+ for i in $SERVICE_NAME-*.jar

Also applies to: 136-136, 147-147


Line range hint 90-90: Ensure variables and commands are properly quoted to prevent word splitting and globbing issues.

- if [ "$(uname)" == "Darwin" ]; then
+ if [ "$(uname)" == "Darwin" ] || [ "$(uname)" == "Linux" ]; then

Also applies to: 92-92, 134-134, 146-146


Line range hint 101-101: Declare and assign separately to avoid masking return values.

- declare -i counter=0
+ declare -i counter
+ counter=0

[!TIP]
Codebase Verification

The result variable is assigned a value but is not used elsewhere in the script. Consider removing it to clean up the code.

  • Line 59: result=$(ps -p "$pid")
Analysis chain

Line range hint 59-59: Verify the usage of the result variable or consider removing it if it's not used.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check if the `result` variable is used elsewhere in the script.

rg --type bash 'result' apollo-adminservice/src/main/scripts/startup.sh

Length of output: 100



Script:

#!/bin/bash
# Description: Check if the `result` variable is used elsewhere in the script.

rg --type sh 'result' apollo-adminservice/src/main/scripts/startup.sh

Length of output: 100

apollo-configservice/src/main/scripts/startup.sh (4)

Line range hint 55-55: Replace iterating over ls output with globs to avoid issues with filenames containing spaces or special characters.

- for i in `ls $SERVICE_NAME-*.jar 2>/dev/null`
+ for i in $SERVICE_NAME-*.jar

Also applies to: 136-136, 147-147


Line range hint 90-90: Ensure variables and commands are properly quoted to prevent word splitting and globbing issues.

- if [ "$(uname)" == "Darwin" ]; then
+ if [ "$(uname)" == "Darwin" ] || [ "$(uname)" == "Linux" ]; then

Also applies to: 92-92, 134-134, 146-146


Line range hint 101-101: Declare and assign separately to avoid masking return values.

- declare -i counter=0
+ declare -i counter
+ counter=0

[!TIP]
Codebase Verification

The result variable is assigned a value but is not used elsewhere in the startup.sh script. Consider removing it to clean up the code.

  • Line 59: result=$(ps -p "$pid")
Analysis chain

Line range hint 59-59: Verify the usage of the result variable or consider removing it if it's not used.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check if the `result` variable is used elsewhere in the script.

rg --type bash 'result' apollo-configservice/src/main/scripts/startup.sh

Length of output: 101



Script:

#!/bin/bash
# Description: Check if the `result` variable is used elsewhere in the script.

rg --type sh 'result' apollo-configservice/src/main/scripts/startup.sh

Length of output: 101

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6218cdd and 1ed5b70.

Files selected for processing (4)
  • CHANGES.md (1 hunks)
  • apollo-adminservice/src/main/scripts/startup.sh (1 hunks)
  • apollo-configservice/src/main/scripts/startup.sh (1 hunks)
  • apollo-portal/src/main/scripts/startup.sh (1 hunks)
Additional context used
Markdownlint
CHANGES.md

1-1: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


8-8: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines

Shellcheck
apollo-portal/src/main/scripts/startup.sh

[warning] 55-55: Iterating over ls output is fragile. Use globs. (SC2045)


[warning] 59-59: result appears unused. Verify use (or export if used externally). (SC2034)


[warning] 90-90: Quote this to prevent word splitting. (SC2046)


[warning] 92-92: Quote this to prevent word splitting. (SC2046)


[warning] 101-101: Declare and assign separately to avoid masking return values. (SC2155)


[warning] 134-134: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164)


[warning] 134-134: Quote this to prevent word splitting. (SC2046)


[error] 136-136: Iterating over ls output is fragile. Use globs. (SC2045)


[warning] 146-146: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164)


[error] 147-147: Iterating over ls output is fragile. Use globs. (SC2045)

apollo-adminservice/src/main/scripts/startup.sh

[warning] 55-55: Iterating over ls output is fragile. Use globs. (SC2045)


[warning] 59-59: result appears unused. Verify use (or export if used externally). (SC2034)


[warning] 90-90: Quote this to prevent word splitting. (SC2046)


[warning] 92-92: Quote this to prevent word splitting. (SC2046)


[warning] 101-101: Declare and assign separately to avoid masking return values. (SC2155)


[warning] 134-134: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164)


[warning] 134-134: Quote this to prevent word splitting. (SC2046)


[error] 136-136: Iterating over ls output is fragile. Use globs. (SC2045)


[warning] 146-146: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164)


[error] 147-147: Iterating over ls output is fragile. Use globs. (SC2045)

apollo-configservice/src/main/scripts/startup.sh

[warning] 55-55: Iterating over ls output is fragile. Use globs. (SC2045)


[warning] 59-59: result appears unused. Verify use (or export if used externally). (SC2034)


[warning] 90-90: Quote this to prevent word splitting. (SC2046)


[warning] 92-92: Quote this to prevent word splitting. (SC2046)


[warning] 101-101: Declare and assign separately to avoid masking return values. (SC2155)


[warning] 134-134: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164)


[warning] 134-134: Quote this to prevent word splitting. (SC2046)


[error] 136-136: Iterating over ls output is fragile. Use globs. (SC2045)


[warning] 146-146: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164)


[error] 147-147: Iterating over ls output is fragile. Use globs. (SC2045)

Additional comments not posted (3)
apollo-portal/src/main/scripts/startup.sh (1)

25-26: Ensure the directory for heap dumps is created during startup.

This change correctly prepares the directory for heap dumps, aligning with the PR's objective to handle OOM errors more gracefully.

apollo-adminservice/src/main/scripts/startup.sh (1)

25-26: Ensure the directory for heap dumps is created during startup.

This change correctly prepares the directory for heap dumps, aligning with the PR's objective to handle OOM errors more gracefully.

apollo-configservice/src/main/scripts/startup.sh (1)

25-26: Ensure the directory for heap dumps is created during startup.

This change correctly prepares the directory for heap dumps, aligning with the PR's objective to handle OOM errors more gracefully.

@nobodyiam nobodyiam merged commit 8e1fe2d into apolloconfig:master Jun 14, 2024
7 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/adminservice apollo-adminservice area/configservice apollo-configservice area/portal apollo-portal lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants