Skip to content

feat(db): remove function for periodic backup of the RocksDB database#74

Open
317787106 wants to merge 1 commit intodevelopfrom
feature/remove_db_backup
Open

feat(db): remove function for periodic backup of the RocksDB database#74
317787106 wants to merge 1 commit intodevelopfrom
feature/remove_db_backup

Conversation

@317787106
Copy link
Copy Markdown
Owner

@317787106 317787106 commented Apr 19, 2026

What does this PR do?

Removes the periodic database backup feature (storage.backup) entirely. This includes the backup configuration class, the AspectJ aspect that intercepted pushBlock to trigger copies, the backup utility, and all associated test fixtures and config files.

Closes tronprotocol#6595.

Why are these changes required?

The storage.backup feature was designed to guard against data corruption from disk failures or abrupt process termination (e.g. kill -9). It has since become more harmful than helpful:

  1. The original threat no longer applies. Extensive testing has confirmed that kill -9 does not corrupt RocksDB, which was the primary motivation for the feature.
  2. Copy times block block synchronisation. As of early 2026, the mainnet state database is close to 3 TB. A single backup copy can take several hours, during which the node cannot sync blocks — a fatal risk to service stability.
  3. A better alternative exists. Operators can deploy a primary–backup pair of full nodes using node.backup (UDP keep-alive failover). If one node becomes unavailable, traffic can be switched to the standby without any file-copy disruption.

Changes:

  • Deleted DbBackupConfig, BackupDbUtil, BackupRocksDBAspect, NeedBeanCondition (common / framework).
  • Removed CommonParameter.dbBackupConfig field and Args.initRocksDbBackupProperty() initialiser.
  • Removed ConfigKey.STORAGE_BACKUP_* constants and the conditional backupRocksDBAspect Spring bean from DefaultConfig.
  • Deleted BackupDbUtilTest and config-test-dbbackup.conf; updated RocksDbDataSourceImplTest and SupplementTest to use TEST_CONF.
  • Configuration change: the storage.backup block is no longer read and has no effect. Nodes carrying this section in their config file can leave it in place without error, but it will be silently ignored.

Backward Compatibility: Not compatible with v4.8.1 or older.

This PR has been tested by:

  • Unit Tests

Follow up

Operators who currently rely on storage.backup should migrate to the node.backup primary–backup failover configuration.

Extra details

N/A

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2026

📝 Walkthrough

Walkthrough

The pull request removes the complete database backup feature from the codebase, including configuration classes, Spring AOP aspects, backup utilities, related test classes, and test configuration files. All backup-related constants and field dependencies are also eliminated.

Changes

Cohort / File(s) Summary
Database Backup Configuration
common/src/main/java/org/tron/common/config/DbBackupConfig.java, common/src/main/java/org/tron/common/parameter/CommonParameter.java, framework/src/main/java/org/tron/core/config/args/ConfigKey.java, framework/src/main/java/org/tron/core/config/args/Args.java
Removed DbBackupConfig class with singleton accessor, configuration fields, and initialization logic. Removed dbBackupConfig field from CommonParameter. Deleted five STORAGE_BACKUP_* configuration key constants. Removed RocksDB backup property initialization from Args.applyConfigParams.
Spring AOP & Backup Aspects
framework/src/main/java/org/tron/core/config/DefaultConfig.java, framework/src/main/java/org/tron/core/db/backup/BackupRocksDBAspect.java, framework/src/main/java/org/tron/core/db/backup/NeedBeanCondition.java
Removed backupRocksDBAspect() Spring bean definition with conditional wiring. Deleted BackupRocksDBAspect class that intercepted pushBlock calls via AOP. Removed NeedBeanCondition Spring Condition implementation that gated bean registration based on RocksDB engine and backup enablement.
Backup Utility Implementation
framework/src/main/java/org/tron/core/db/backup/BackupDbUtil.java
Deleted BackupDbUtil class responsible for orchestrating database backup operations, managing persistent backup state transitions, and performing block-level backup sequences across two configured backup indices.
Test Updates & Removals
framework/src/test/java/org/tron/core/db/backup/BackupDbUtilTest.java, framework/src/test/java/org/tron/program/SupplementTest.java, framework/src/test/java/org/tron/core/db/backup/RocksDbDataSourceImplTest.java, plugins/src/test/java/org/tron/plugins/DbLiteTest.java
Removed entire BackupDbUtilTest class with backup state persistence test. Removed DbBackupConfig initialization and usage from SupplementTest. Updated RocksDbDataSourceImplTest to use TEST_CONF instead of DBBACKUP_CONF. Removed DbBackupConfig instance initialization from DbLiteTest.
Test Configuration
framework/src/test/resources/config-test-dbbackup.conf
Deleted entire test configuration file containing RocksDB and backup configuration settings (401 lines).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hoppy farewell to backups past,
No more states that were meant to last,
Bak1, Bak2, and AspectJ—
All hopped away without delay!
Cleaner code, a lighter load,
Cleared the path down backup road! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removal of the RocksDB database backup functionality, which is the primary objective evidenced by deletions across multiple backup-related classes, configuration keys, and test files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/remove_db_backup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@317787106 317787106 changed the title feature(db): remove rocksdb database backup feat(db): remove rocksdb database backup Apr 19, 2026
Copy link
Copy Markdown

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
framework/src/test/java/org/tron/common/storage/rocksdb/RocksDbDataSourceImplTest.java (1)

126-140: ⚠️ Potential issue | 🟡 Minor

Remove backupAndDelete test and its corresponding dead code methods.

The backup() and deleteDbBakPath() methods have no production callers—they are invoked only by this test. Since the PR removes the database backup feature, these low-level RocksDB APIs appear to be dead code. Remove the test and consider removing the unused methods from RocksDbDataSourceImpl as well.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@framework/src/test/java/org/tron/common/storage/rocksdb/RocksDbDataSourceImplTest.java`
around lines 126 - 140, Delete the JUnit test method backupAndDelete in
RocksDbDataSourceImplTest and remove the corresponding unused production methods
backup(...) and deleteDbBakPath(...) from the RocksDbDataSourceImpl class (and
any trivial helpers that only support them); ensure you also remove any imports
or test utilities used solely by that test and run tests to confirm no other
callers reference backup(...) or deleteDbBakPath(...).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@framework/src/test/java/org/tron/common/storage/rocksdb/RocksDbDataSourceImplTest.java`:
- Around line 126-140: Delete the JUnit test method backupAndDelete in
RocksDbDataSourceImplTest and remove the corresponding unused production methods
backup(...) and deleteDbBakPath(...) from the RocksDbDataSourceImpl class (and
any trivial helpers that only support them); ensure you also remove any imports
or test utilities used solely by that test and run tests to confirm no other
callers reference backup(...) or deleteDbBakPath(...).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c667cd3-3c5e-41cb-9a1d-45e49ddc5bfa

📥 Commits

Reviewing files that changed from the base of the PR and between 2de63bb and 3fdd69f.

📒 Files selected for processing (13)
  • common/src/main/java/org/tron/common/config/DbBackupConfig.java
  • common/src/main/java/org/tron/common/parameter/CommonParameter.java
  • framework/src/main/java/org/tron/core/config/DefaultConfig.java
  • framework/src/main/java/org/tron/core/config/args/Args.java
  • framework/src/main/java/org/tron/core/config/args/ConfigKey.java
  • framework/src/main/java/org/tron/core/db/backup/BackupDbUtil.java
  • framework/src/main/java/org/tron/core/db/backup/BackupRocksDBAspect.java
  • framework/src/main/java/org/tron/core/db/backup/NeedBeanCondition.java
  • framework/src/test/java/org/tron/common/storage/rocksdb/RocksDbDataSourceImplTest.java
  • framework/src/test/java/org/tron/core/db/backup/BackupDbUtilTest.java
  • framework/src/test/java/org/tron/program/SupplementTest.java
  • framework/src/test/resources/config-test-dbbackup.conf
  • plugins/src/test/java/org/tron/plugins/DbLiteTest.java
💤 Files with no reviewable changes (12)
  • plugins/src/test/java/org/tron/plugins/DbLiteTest.java
  • common/src/main/java/org/tron/common/parameter/CommonParameter.java
  • framework/src/test/java/org/tron/program/SupplementTest.java
  • framework/src/main/java/org/tron/core/db/backup/NeedBeanCondition.java
  • framework/src/main/java/org/tron/core/config/args/Args.java
  • framework/src/test/resources/config-test-dbbackup.conf
  • framework/src/main/java/org/tron/core/config/DefaultConfig.java
  • framework/src/main/java/org/tron/core/db/backup/BackupRocksDBAspect.java
  • framework/src/test/java/org/tron/core/db/backup/BackupDbUtilTest.java
  • framework/src/main/java/org/tron/core/config/args/ConfigKey.java
  • common/src/main/java/org/tron/common/config/DbBackupConfig.java
  • framework/src/main/java/org/tron/core/db/backup/BackupDbUtil.java

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 13 files

@317787106 317787106 changed the title feat(db): remove rocksdb database backup feat(db): remove functionality for periodic backup of the RocksDB database Apr 23, 2026
@317787106 317787106 changed the title feat(db): remove functionality for periodic backup of the RocksDB database feat(db): remove function for periodic backup of the RocksDB database Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Remove periodic database backup in favor of dual-node failover

1 participant