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

Improve usability of snapshots saved by snapshotting node #749

Merged
merged 3 commits into from
Nov 6, 2023
Merged

Conversation

roy-dydx
Copy link
Contributor

@roy-dydx roy-dydx commented Nov 3, 2023

Changelist

  • Prune everything by setting pruning setting to everything (only last 2 states retained).
  • Change file names so it's properly sorted.

Test Plan

  • Deploy to dev and see that new snapshot still got saved

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Copy link
Contributor

coderabbitai bot commented Nov 3, 2023

Walkthrough

The recent changes in the snapshot.sh script involve modifying the pruning configuration in the app.toml file and updating the SNAP_NAME variable. The pruning configuration is now set to "nothing", and the SNAP_NAME variable has been modified to include the date and time in the filename.

Changes

File Path Summary
protocol/testing/snapshotting/snapshot.sh Added a line to set the pruning configuration to "nothing" in the app.toml file. Modified the format of the SNAP_NAME variable to include the date and time in the filename.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

@roy-dydx roy-dydx force-pushed the roy/snap branch 2 times, most recently from c697ec1 to 7257a8e Compare November 3, 2023 19:24
@roy-dydx roy-dydx marked this pull request as ready for review November 3, 2023 21:11
Copy link
Contributor

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ea4f689 and 650b2ee.
Files selected for processing (1)
  • protocol/testing/snapshotting/snapshot.sh (2 hunks)
Additional comments: 2
protocol/testing/snapshotting/snapshot.sh (2)
  • 87-91: The change to the pruning configuration is a significant one. It's important to ensure that this change doesn't negatively impact the performance of the system or lead to unexpected behavior. Please verify that the system can handle retaining only the last two states and that this doesn't cause any issues with data integrity or system performance.

  • 105-108: The change to include the date and time in the snapshot filename is a good one for usability. However, it's important to ensure that this change doesn't cause any issues with existing systems that might be expecting the old filename format. Please verify that all systems that interact with these snapshots can handle the new filename format.

@vincentwschau
Copy link
Contributor

vincentwschau commented Nov 3, 2023

Also update the script here? Probably should just pull the snapshot script from this repo in the setup script in the other repos that push up docker images.

@@ -99,7 +102,7 @@ while true; do
kill -TERM $(pidof cosmovisor)

log_this "Creating new snapshot"
SNAP_NAME=$(echo "${CHAIN_ID}_$(date '+%Y-%m-%d-%M-%H').tar.gz")
Copy link
Contributor

Choose a reason for hiding this comment

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

😅

@roy-dydx roy-dydx merged commit 65f7f8d into main Nov 6, 2023
9 of 10 checks passed
@roy-dydx roy-dydx deleted the roy/snap branch November 6, 2023 15:57
Copy link
Contributor

@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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 650b2ee and bc11c10.
Files selected for processing (1)
  • protocol/testing/snapshotting/snapshot.sh (2 hunks)

Comment on lines 87 to +91
dydxprotocold init --chain-id=${CHAIN_ID} --home /dydxprotocol/chain/local_node local_node
curl -X GET ${genesis_file_rpc_address}/genesis | jq '.result.genesis' > /dydxprotocol/chain/local_node/config/genesis.json

# Set pruning to prune all but the last two states. Prevents snapshots from getting too big.
sed -i 's/pruning = "default"/pruning = "everything"/' /dydxprotocol/chain/local_node/config/app.toml
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment on line 90 and the code on line 91 seem to contradict each other. The comment says that all but the last two states are pruned, but the code sets pruning to "everything". Please verify this.

- # Set pruning to prune all but the last two states. Prevents snapshots from getting too big.
- sed -i 's/pruning = "default"/pruning = "everything"/' /dydxprotocol/chain/local_node/config/app.toml
+ # Set pruning to prune everything. Prevents snapshots from getting too big.
+ sed -i 's/pruning = "default"/pruning = "everything"/' /dydxprotocol/chain/local_node/config/app.toml

Commitable suggestion

[!IMPORTANT]
Carefully review the code before committing. Make sure it correctly replaces the highlighted code, has no missing lines and indentaion issues.

Suggested change
dydxprotocold init --chain-id=${CHAIN_ID} --home /dydxprotocol/chain/local_node local_node
curl -X GET ${genesis_file_rpc_address}/genesis | jq '.result.genesis' > /dydxprotocol/chain/local_node/config/genesis.json
# Set pruning to prune all but the last two states. Prevents snapshots from getting too big.
sed -i 's/pruning = "default"/pruning = "everything"/' /dydxprotocol/chain/local_node/config/app.toml
# Set pruning to prune everything. Prevents snapshots from getting too big.
sed -i 's/pruning = "default"/pruning = "everything"/' /dydxprotocol/chain/local_node/config/app.toml

Comment on lines 102 to 108
kill -TERM $(pidof cosmovisor)

log_this "Creating new snapshot"
SNAP_NAME=$(echo "${CHAIN_ID}_$(date '+%Y-%m-%d-%M-%H').tar.gz")
SNAP_NAME=$(echo "${CHAIN_ID}_$(date '+%Y-%m-%d-%H-%M').tar.gz")
tar cvzf ${SNAP_PATH}/${SNAP_NAME} ${DATA_PATH}
aws s3 cp ${SNAP_PATH}/${SNAP_NAME} s3://${s3_snapshot_bucket}/ --region ap-northeast-1 --debug || true
rm -rf ${SNAP_PATH}/${SNAP_NAME}
Copy link
Contributor

Choose a reason for hiding this comment

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

The new format for SNAP_NAME is a good improvement for better sorting and access of snapshots. However, consider using a more precise timestamp format to avoid potential conflicts if two snapshots are created within the same minute.

- SNAP_NAME=$(echo "${CHAIN_ID}_$(date '+%Y-%m-%d-%H-%M').tar.gz")
+ SNAP_NAME=$(echo "${CHAIN_ID}_$(date '+%Y-%m-%d-%H-%M-%S').tar.gz")

Commitable suggestion

[!IMPORTANT]
Carefully review the code before committing. Make sure it correctly replaces the highlighted code, has no missing lines and indentaion issues.

Suggested change
kill -TERM $(pidof cosmovisor)
log_this "Creating new snapshot"
SNAP_NAME=$(echo "${CHAIN_ID}_$(date '+%Y-%m-%d-%M-%H').tar.gz")
SNAP_NAME=$(echo "${CHAIN_ID}_$(date '+%Y-%m-%d-%H-%M').tar.gz")
tar cvzf ${SNAP_PATH}/${SNAP_NAME} ${DATA_PATH}
aws s3 cp ${SNAP_PATH}/${SNAP_NAME} s3://${s3_snapshot_bucket}/ --region ap-northeast-1 --debug || true
rm -rf ${SNAP_PATH}/${SNAP_NAME}
kill -TERM $(pidof cosmovisor)
log_this "Creating new snapshot"
- SNAP_NAME=$(echo "${CHAIN_ID}_$(date '+%Y-%m-%d-%H-%M').tar.gz")
+ SNAP_NAME=$(echo "${CHAIN_ID}_$(date '+%Y-%m-%d-%H-%M-%S').tar.gz")
tar cvzf ${SNAP_PATH}/${SNAP_NAME} ${DATA_PATH}
aws s3 cp ${SNAP_PATH}/${SNAP_NAME} s3://${s3_snapshot_bucket}/ --region ap-northeast-1 --debug || true
rm -rf ${SNAP_PATH}/${SNAP_NAME}

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

Successfully merging this pull request may close these issues.

3 participants