Skip to content
This repository was archived by the owner on Mar 12, 2026. It is now read-only.

refactor!(wal): factor out wal-rocksdb#1231

Closed
tisonkun wants to merge 4 commits into
apache:mainfrom
tisonkun:opt-wal-impl
Closed

refactor!(wal): factor out wal-rocksdb#1231
tisonkun wants to merge 4 commits into
apache:mainfrom
tisonkun:opt-wal-impl

Conversation

@tisonkun

Copy link
Copy Markdown
Member

This is a possible impl for #1222 (comment).

But still the transitive solution introduce too much cfg code IMO, while otherwise the deeply coupled code cannot be easily opt out.

Send for preview and demonstrate the solution direction. Perhaps we can have a better solution.

Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
/// Config for wal based on RocksDB
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(default)]
pub struct RocksDBConfig {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This config can be moved to wal-rocksdb while tests uses should be updated.

/// Options for wal storage backend
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(tag = "type")]
pub enum WalStorageConfig {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

But this enum cannot be moved to any specific wal-impl, not suitable for wal also.

Comment thread analytic_engine/src/setup.rs
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(tag = "type")]
pub enum WalStorageConfig {
#[cfg(feature = "wal-rocksdb")]

@jiacai2050 jiacai2050 Sep 27, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this shouldn't be in feature gate, we should throw error at runtime when user configure to use rocksdb as WAL for binary built without this feature.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

But the RocksDBConfig transitively depends on rocksdb so when we build a binary without rocksdb, the RocksDB config cannot be constructed also.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the RocksDB config cannot be constructed also.

In this case, a dummy struct could be constructed to make compile success. Something like this:

#[cfg(feature = "wal-rocksdb")]
RocksDBConfig = wal-rocksdb::config
#[cfg(not(feature = "wal-rocksdb"))]
RocksDBConfig = struct {};

Comment thread analytic_engine/src/setup.rs
Comment thread Cargo.toml
tonic = "0.8.1"
tokio = { version = "1.29", features = ["full"] }
wal = { path = "wal" }
wal = { path = "src/wal" }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if this is necessary to split different wal implementation to different crates, any advantages?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's possible we retain the code in wal crate and guard them with different feature gate. Factor out impl into dedicated crates is for:

Generally, I don't have a strong preference, either should be viable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OK, I also don't have strong preference, keep it as it's now.

jiacai2050 pushed a commit that referenced this pull request Oct 17, 2023
## Rationale

Ref -
#1231 (comment).

## Detailed Changes

See the commit messages.

## Test Plan

Code refactor. All existing tests should pass.

---------

Signed-off-by: tison <wander4096@gmail.com>
jiacai2050 pushed a commit that referenced this pull request Oct 18, 2023
## Rationale

Part of #1231.

This change itself is self-contained to merge (i.e., not
half-complelted). Since that I may not have enough time to continue the
next few days, I post this first for a merge to avoid code conflict.

## Detailed Changes

See the commit message.

## Test Plan

Refactor. Should pass all existing tests.

---------

Signed-off-by: tison <wander4096@gmail.com>
@tisonkun

Copy link
Copy Markdown
Member Author

Superseded by #1272.

@tisonkun tisonkun closed this Oct 19, 2023
@tisonkun tisonkun deleted the opt-wal-impl branch October 19, 2023 02:57
ShiKaiWi pushed a commit that referenced this pull request Oct 21, 2023
## Rationale

Supersede #1231

After compile time with clean - 

```
    Finished dev [unoptimized + debuginfo] target(s) in 2m 18s
```

## Detailed Changes

Conditionally compile wal impls with feature flags.

## Test Plan

Code refactor. All existing tests should pass.

---------

Signed-off-by: tison <wander4096@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants