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

Allow database migration upon adding new database column family to schema #1851

Merged

Conversation

simrankedia
Copy link
Contributor

@simrankedia simrankedia commented Apr 21, 2024

Adds migration capabilities (allows adding new column family to existing database) to RocksDB instance. This change makes sure RocksDB open is always requested with the existing set of column families and all new column families are later created once opened.

Before requesting review

  • I have reviewed the code myself

@CLAassistant
Copy link

CLAassistant commented Apr 21, 2024

CLA assistant check
All committers have signed the CLA.

@xgreenx
Copy link
Collaborator

xgreenx commented Apr 22, 2024

Answering your comment in the issue:

@Voxelot I have tried to raise a PR to fix this issue #1851 - please let me know if the direction is correct - I will accordingly complete and release a new PR with tests etc.

You are welcome to contribute, and yeah, it is the right direction.

I created a test case #1853 to prove that the fix works. Could you rebase your PR to use this branch with the test case, please?

@xgreenx xgreenx marked this pull request as draft April 22, 2024 09:24
@simrankedia simrankedia changed the base branch from master to feature/support-new-tables-rocksdb April 22, 2024 22:05
@simrankedia simrankedia marked this pull request as ready for review April 22, 2024 22:13
crates/fuel-core/src/state/rocks_db.rs Outdated Show resolved Hide resolved
crates/fuel-core/src/state/rocks_db.rs Outdated Show resolved Hide resolved
crates/fuel-core/src/state/rocks_db.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@xgreenx xgreenx left a comment

Choose a reason for hiding this comment

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

Could you fix CI please?=) You can run locally ./ci_checks.sh to perform all CI checks

@simrankedia
Copy link
Contributor Author

Could you fix CI please?=) You can run locally ./ci_checks.sh to perform all CI checks

@xgreenx I am seeing the following issue upon running the checks, which seems unrelated.
Screenshot 2024-04-23 at 00 20 23

@simrankedia simrankedia force-pushed the fix_rocksdb branch 3 times, most recently from 6334d6a to da71786 Compare April 22, 2024 23:46
@simrankedia simrankedia changed the title Allow database migration upon adding new database column family to sc… Allow database migration upon adding new database column family to schema Apr 22, 2024
@xgreenx
Copy link
Collaborator

xgreenx commented Apr 23, 2024

The change fails most of tests=)
image

@xgreenx
Copy link
Collaborator

xgreenx commented Apr 23, 2024

I am seeing the following issue upon running the checks, which seems unrelated.

I would suggest you to use rust 1.75=)

@simrankedia
Copy link
Contributor Author

The change fails most of tests=)

image

Yes, I will look into it and get back. Didn't get a chance today.

@simrankedia
Copy link
Contributor Author

request as draft April 24, 2024 14:14

I have fixed the original issue and the failing tests have been fixed. However, upon further running the checks I see some 5 more tests failing:

    poa::p2p::test_poa_multiple_producers
    sync::test_multiple_producers_different_keys
    sync::test_partitions_larger_groups::partition_with_100_txs_8_validators_4_partitions
    sync::test_partitions_larger_groups::partition_with_10_txs_8_validators_4_partitions
    sync::test_partitions_larger_groups::partition_with_1_tx_3_validators_3_partitions

These are not directly related to my changes atleast - I will investigate more tomorrow. Let me know if you have any idea till then. Thanks

@simrankedia simrankedia marked this pull request as ready for review April 25, 2024 09:13
@simrankedia
Copy link
Contributor Author

request as draft April 24, 2024 14:14

I have fixed the original issue and the failing tests have been fixed. However, upon further running the checks I see some 5 more tests failing:

    poa::p2p::test_poa_multiple_producers
    sync::test_multiple_producers_different_keys
    sync::test_partitions_larger_groups::partition_with_100_txs_8_validators_4_partitions
    sync::test_partitions_larger_groups::partition_with_10_txs_8_validators_4_partitions
    sync::test_partitions_larger_groups::partition_with_1_tx_3_validators_3_partitions

These are not directly related to my changes atleast - I will investigate more tomorrow. Let me know if you have any idea till then. Thanks

@xgreenx Slightly by increasing this time_limit (https://github.com/FuelLabs/fuel-core/blob/master/crates/fuel-core/src/p2p_test_helpers.rs#L383) all test passes - I am running an experiment to understand what kind of limit to use - but wanted to check if there are any specific constraints that needs to be followed here?

Comment on lines +251 to +255
for (name, opt) in cf_descriptors_to_create {
db.create_cf(name, &opt)
.map_err(|e| DatabaseError::Other(e.into()))?;
}
Ok(db)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it makes sense to move this loop after db is opened(below of the match statement). In this case you also will handle the case of the error with repair.

Self::cf_opts(i, &block_opts),
)
});
DB::open_cf_descriptors(&opts, &path, cf_descriptors)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
DB::open_cf_descriptors(&opts, &path, cf_descriptors)
DB::open_cf_descriptors(&opts, &path, cf_descriptors_to_open)

@xgreenx xgreenx merged commit 4165449 into FuelLabs:feature/support-new-tables-rocksdb Apr 29, 2024
30 of 33 checks passed
@xgreenx xgreenx mentioned this pull request Apr 30, 2024
xgreenx added a commit that referenced this pull request Apr 30, 2024
## Version v0.26.0

### Fixed

#### Breaking

- [#1868](#1868): Include the
`event_inbox_root` in the header hash. Changed types of the
`transactions_count` to `u16` and `message_receipt_count` to `u32`
instead of `u64`. Updated the application hash root calculation to not
pad numbers.
- [#1866](#1866): Fixed a
runtime panic that occurred when restarting a node. The panic happens
when the relayer database is already populated, and the relayer attempts
an empty commit during start up. This invalid commit is removed in this
PR.
- [#1871](#1871): Fixed
`block` endpoint to return fetch the blocks from both databases after
regenesis.
- [#1856](#1856): Replaced
instances of `Union` with `Enum` for GraphQL definitions of
`ConsensusParametersVersion` and related types. This is needed because
`Union` does not support multiple `Version`s inside discriminants or
empty variants.
- [#1870](#1870): Fixed
benchmarks for the `0.25.3`.
- [#1870](#1870): Improves the
performance of getting the size of the contract from the
`InMemoryTransaction`.
- [#1851](#1851): Provided
migration capabilities (enabled addition of new column families) to
RocksDB instance.

### Added 

- [#1853](#1853): Added a test
case to verify the database's behavior when new columns are added to the
RocksDB database.
- [#1860](#1860): Regenesis
now preserves `FuelBlockIdsToHeights` off-chain table.

### Changed

- [#1847](#1847): Simplify the
validation interface to use `Block`. Remove `Validation` variant of
`ExecutionKind`.
- [#1832](#1832): Snapshot
generation can be cancelled. Progress is also reported.
- [#1837](#1837): Refactor the
executor and separate validation from the other use cases

## What's Changed
* Weekly `cargo update` by @github-actions in
#1850
* Refactor/separate validation from other executions by @MitchTurner in
#1837
* fix: Use `Enum` for `ConsensusParametersVersion` and related types by
@bvrooman in #1856
* feat: snapshot generation graceful shutdown by @segfault-magnet in
#1832
* regenesis: migrate FuelBlockIdsToHeights by @Dentosal in
#1860
* Weekly `cargo update` by @github-actions in
#1869
* Refactor/Simplify validation logic by @MitchTurner in
#1847
* Fixed `block` endpoint to return fetch the blocks from both databases
after regenesis by @xgreenx in
#1871
* Add Eq and Partial Eq to tx response and status by @MujkicA in
#1872
* test: restart with relayer data by @bvrooman in
#1866
* Fix `BlockHeader` hash by @MitchTurner in
#1868
* Added a test for the case of adding new columns into the existing
RocksDB database by @xgreenx in
#1853
* Fixed benchmarks for the `0.25.3` by @xgreenx in
#1870


**Full Changelog**:
v0.25.3...v0.26.0
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.

Make RocksDB more upgradeable
3 participants