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

build on windows system. #322

Merged
merged 1 commit into from
Jul 27, 2023
Merged

build on windows system. #322

merged 1 commit into from
Jul 27, 2023

Conversation

MichaelScofield
Copy link
Contributor

@MichaelScofield MichaelScofield commented Jul 4, 2023

Let cargo build pass under windows system:

  1. use windows os specific symlink API in fork.rs
  2. use different LogFd implementations in each os. Guarded (or choosen) by feature flags
    • for non-linux or non-unix system, use the plain std::fs APIs instead
    • for linux and unix system, still use the nix raw bindings

@MichaelScofield
Copy link
Contributor Author

@tabokie PTAL

Copy link
Member

@tabokie tabokie left a comment

Choose a reason for hiding this comment

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

Some CI changes that're needed:

src/fork.rs Show resolved Hide resolved
src/env/log_fd.rs Outdated Show resolved Hide resolved
src/env/log_fd.rs Show resolved Hide resolved
src/env/log_fd/nix.rs Outdated Show resolved Hide resolved
@MichaelScofield
Copy link
Contributor Author

@tabokie PTAL. Can you approve the workflow to run so I can debug the windows build in CI?

@MichaelScofield
Copy link
Contributor Author

@tabokie can you make this PR always run workflow? Need another approval again. Debugging github workflow is a pain, especially for os = windows. I can see more commits to debug it in the future.

@tabokie
Copy link
Member

tabokie commented Jul 9, 2023

I don't have the permission to do that. It's weird though because my fork repo runs the workflow just fine: https://github.com/tabokie/raft-engine/actions, I wonder why your fork repo ignores the workflow file.

@tabokie
Copy link
Member

tabokie commented Jul 10, 2023

@MichaelScofield You can work around this by merging another small PR first. E.g. Open another PR to update clap manually (#306)

@MichaelScofield
Copy link
Contributor Author

@tabokie
Having trouble with building pingcap grpc in windows os: https://github.com/tikv/raft-engine/actions/runs/5493202302/jobs/10013725416 . Any ideas? Thx!

@tabokie
Copy link
Member

tabokie commented Jul 12, 2023

It can build now, you just need to fix the tests.

@MichaelScofield
Copy link
Contributor Author

Running into infamous "access denied (os error 5)" error in windows. Convert this PR to draft first, to reduce github notification noise.

@MichaelScofield MichaelScofield marked this pull request as draft July 12, 2023 15:34
@codecov
Copy link

codecov bot commented Jul 16, 2023

Codecov Report

Patch coverage: 95.34% and no project coverage change.

Comparison is base (58041ad) 97.98% compared to head (94a96db) 97.99%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #322   +/-   ##
=======================================
  Coverage   97.98%   97.99%           
=======================================
  Files          31       33    +2     
  Lines       12329    12388   +59     
=======================================
+ Hits        12081    12140   +59     
  Misses        248      248           
Files Changed Coverage Δ
src/env/mod.rs 85.00% <ø> (ø)
src/file_pipe_log/pipe.rs 98.10% <ø> (ø)
src/fork.rs 100.00% <ø> (ø)
src/lib.rs 100.00% <ø> (ø)
src/env/log_fd/unix.rs 91.15% <91.15%> (ø)
src/env/default.rs 93.75% <100.00%> (+1.60%) ⬆️
src/env/log_fd/plain.rs 100.00% <100.00%> (ø)
src/swappy_allocator.rs 99.34% <100.00%> (+<0.01%) ⬆️
tests/failpoints/test_engine.rs 99.90% <100.00%> (ø)
tests/failpoints/test_io_error.rs 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MichaelScofield MichaelScofield marked this pull request as ready for review July 16, 2023 12:44
@MichaelScofield
Copy link
Contributor Author

@tabokie PTAL. The tests are all passed (at least in my repo's action, see here). Let's approve the workflow in this PR to see how it goes!

tabokie
tabokie previously approved these changes Jul 17, 2023
Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Show resolved Hide resolved
src/file_pipe_log/pipe.rs Outdated Show resolved Hide resolved
use std::path::Path;
use std::sync::Arc;

pub struct LogFd(Arc<RwLock<File>>);
Copy link
Member

Choose a reason for hiding this comment

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

This implementation kind of defeats the point of Handle abstraction, which is to be efficiently shared between multiple readers/writers. I like seeing a fallback solution that covers all platforms other than Windows, but this implementation is too inefficient for production use.

I can think of two ways to go around this:

(1) use raw windows HANDLE here like in #69, it has the downside of windows-only.
(2) further separate LogFile into unix and windows version. The windows version looks something like below. It has the downside of needing to port lots of failpoints again.

struct LogFd(File);
struct LogFile(File);
impl LogFd {
  fn new_writer(&self) -> LogFile {
    LogFile(self.0.try_clone().unwrap())
  }
}

@tabokie
Copy link
Member

tabokie commented Jul 21, 2023

@MichaelScofield #325 is merged. Feel free to ask questions. #322 (comment) might be too much work for this PR, you can follow up in another one or let me handle it later.

@MichaelScofield
Copy link
Contributor Author

@tabokie Sorry for the late reply, busy week.

I actually considered using the raw Windows API earlier. However, skimmed through the "windows" crate and the "official win32 API docs", I find it's not a quick and easy task. It requires detailed understanding of Windows filesystem to do it well, which I'm currently lacking of, nor do I have the time to study it. Besides, the windows binding APIs are all "unsafe" to call in rust. So I decide to switch back to the good old std fs, make it right first.

I'll make the features worked in the new test matrix this weekend.

@MichaelScofield
Copy link
Contributor Author

@tabokie tests are ok now, PTAL

.github/workflows/rust.yml Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@MichaelScofield
Copy link
Contributor Author

@tabokie PTAL

Now the "test_matrix" is only used in coverage job, and only runs under ubuntu.

Copy link
Member

@tabokie tabokie left a comment

Choose a reason for hiding this comment

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

Rest LG.

.github/workflows/rust.yml Outdated Show resolved Hide resolved
Copy link
Member

@tabokie tabokie left a comment

Choose a reason for hiding this comment

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

DCO needs fixing.

Makefile Outdated Show resolved Hide resolved
Signed-off-by: luofucong <luofc@foxmail.com>
@MichaelScofield
Copy link
Contributor Author

@tabokie PTAL

@tabokie
Copy link
Member

tabokie commented Jul 26, 2023

GitHub action space is not enough.. I'll take a look tomorrow.

Copy link
Member

@tabokie tabokie left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks

@tabokie tabokie merged commit 2dcaf5b into tikv:master Jul 27, 2023
8 checks passed
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.

2 participants