Skip to content

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

Open
317787106 wants to merge 2 commits intodevelopfrom
feature/remove_db_backup
Open

feat(db): remove function for periodic backup of the RocksDB database#74
317787106 wants to merge 2 commits 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

Summary by CodeRabbit

Release Notes

  • Chores

    • Removed database backup functionality, including automatic RocksDB backup scheduling and configuration options for backup paths and frequency settings.
  • Tests

    • Updated test configurations and removed backup-related test cases.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6cadfb00-e107-47ad-8a59-1be9f8a027bb

📥 Commits

Reviewing files that changed from the base of the PR and between 3fdd69f and 4cb3417.

📒 Files selected for processing (3)
  • framework/Daily_Build_Report
  • framework/prop.properties
  • prop.properties
💤 Files with no reviewable changes (1)
  • framework/Daily_Build_Report

📝 Walkthrough

Walkthrough

The pull request removes the periodic database backup feature: configuration, conditional bean wiring, AOP aspect, backup utility, related tests, and a test configuration file; all storage.backup keys and usages are deleted.

Changes

Cohort / File(s) Summary
Database Backup Config & Params
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 and singleton, removed dbBackupConfig field, deleted STORAGE_BACKUP_* config keys, and removed RocksDB backup init from Args.applyConfigParams.
Spring Config & Condition
framework/src/main/java/org/tron/core/config/DefaultConfig.java, framework/src/main/java/org/tron/core/db/backup/NeedBeanCondition.java
Deleted conditional Spring bean registration for the backup aspect and removed the NeedBeanCondition that gated bean instantiation.
AOP Aspect
framework/src/main/java/org/tron/core/db/backup/BackupRocksDBAspect.java
Removed aspect that intercepted Manager.pushBlock(BlockCapsule) to trigger periodic DB backups and its after-throwing advice.
Backup Core Logic
framework/src/main/java/org/tron/core/db/backup/BackupDbUtil.java
Deleted backup orchestration utility that managed persistent backup state, selected backup index, performed delete/copy operations for RocksDB instances, and logged timing/errors.
Tests & Test Config
framework/src/test/java/org/tron/core/db/backup/BackupDbUtilTest.java, framework/src/test/resources/config-test-dbbackup.conf, framework/src/test/java/org/tron/program/SupplementTest.java, framework/src/test/java/org/tron/common/storage/rocksdb/RocksDbDataSourceImplTest.java, plugins/src/test/java/org/tron/plugins/DbLiteTest.java
Removed BackupDbUtilTest and the config-test-dbbackup.conf; removed DbBackupConfig setup/usages from tests; adjusted one RocksDB test to use a different test config.
Misc
framework/Daily_Build_Report
Removed a single report line (file now empty).

Sequence Diagram(s)

sequenceDiagram
    participant Manager
    participant BackupAspect as BackupRocksDBAspect
    participant Args
    participant BackupUtil as BackupDbUtil
    participant SnapshotMgr as SnapshotManager
    participant RocksDB
    Manager->>BackupAspect: pushBlock(block)
    BackupAspect->>Args: check dbBackupConfig & frequency
    Note right of Args: decide whether backup is enabled\nand whether block.num % frequency == 0
    Args-->>BackupAspect: decision
    alt backup enabled & threshold met
        BackupAspect->>BackupUtil: doBackup(block)
        BackupUtil->>SnapshotMgr: list chain databases
        SnapshotMgr-->>BackupUtil: DB instances
        BackupUtil->>RocksDB: perform delete/copy per index
        RocksDB-->>BackupUtil: success/error
        BackupUtil-->>BackupAspect: result/log
    else skip backup
        BackupAspect-->>Manager: continue
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through config, code, and test,

Bak1 and Bak2 now take a rest.
The aspect hopped off, util walked away,
Tests trimmed down to lighter play.
A little rabbit cheers: less bulk today!

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing the periodic RocksDB backup feature.
Linked Issues check ✅ Passed All coding requirements from issue #6595 are met: storage.backup feature, code, tests, and configuration are completely removed.
Out of Scope Changes check ✅ Passed All changes directly relate to removing the database backup feature; no unrelated modifications were introduced.

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

✨ Finishing Touches
🧪 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