Skip to content

Fix for data are not flushed to disk in context of Kvs::flush()#254

Open
tizava wants to merge 4 commits intoeclipse-score:mainfrom
etas-contrib:cpp_write_sync
Open

Fix for data are not flushed to disk in context of Kvs::flush()#254
tizava wants to merge 4 commits intoeclipse-score:mainfrom
etas-contrib:cpp_write_sync

Conversation

@tizava
Copy link
Copy Markdown
Contributor

@tizava tizava commented Mar 11, 2026

Fixes: 252

In old implementation data were only written using std::fostream, which is an asynchronous API.
Flush to the physical storage is required as well to ensure all the data are persisted.

The std::ostream::flush() will only flush the C++ buffer to OS (Not to the disk), therefore fstream API has been replaced with cstdio.
Posix fdatasync() API, which is synchronous is now called to ensure all buffers are properly flushed.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 11, 2026

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.4.2) and connecting to it...
INFO: Invocation ID: 7d683f8a-f542-43b2-8306-32fd1dd43b2d
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
WARNING: For repository 'rules_python', the root module requires module version rules_python@1.4.1, but got rules_python@1.8.3 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'score_rust_policies', the root module requires module version score_rust_policies@0.0.4, but got score_rust_policies@0.0.5 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'rules_cc', the root module requires module version rules_cc@0.1.2, but got rules_cc@0.2.16 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'googletest', the root module requires module version googletest@1.17.0.bcr.1, but got googletest@1.17.0.bcr.2 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'google_benchmark', the root module requires module version google_benchmark@1.9.4, but got google_benchmark@1.9.5 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
Computing main repo mapping: 
Loading: 
Loading: 3 packages loaded
Loading: 3 packages loaded
    currently loading: 
Loading: 3 packages loaded
    currently loading: 
Loading: 3 packages loaded
    currently loading: 
Analyzing: target //:license-check (4 packages loaded, 0 targets configured)
Analyzing: target //:license-check (4 packages loaded, 0 targets configured)

Analyzing: target //:license-check (71 packages loaded, 10 targets configured)

Analyzing: target //:license-check (100 packages loaded, 23 targets configured)

Analyzing: target //:license-check (157 packages loaded, 2311 targets configured)

Analyzing: target //:license-check (165 packages loaded, 2364 targets configured)

Analyzing: target //:license-check (165 packages loaded, 2364 targets configured)

Analyzing: target //:license-check (165 packages loaded, 2364 targets configured)

Analyzing: target //:license-check (168 packages loaded, 4252 targets configured)

Analyzing: target //:license-check (171 packages loaded, 5502 targets configured)

Analyzing: target //:license-check (172 packages loaded, 5510 targets configured)

Analyzing: target //:license-check (172 packages loaded, 5510 targets configured)

Analyzing: target //:license-check (172 packages loaded, 5510 targets configured)

Analyzing: target //:license-check (172 packages loaded, 5510 targets configured)

Analyzing: target //:license-check (199 packages loaded, 5722 targets configured)
[11 / 17] Creating runfiles tree bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/score_tooling+/dash/tool/formatters/dash_format_converter.runfiles [for tool]; 0s local
INFO: From Generating Dash formatted dependency file ...:
INFO: Successfully converted 66 packages from Cargo.lock to bazel-out/k8-fastbuild/bin/formatted.txt
Analyzing: target //:license-check (199 packages loaded, 5722 targets configured)
[14 / 17] JavaToolchainCompileClasses external/rules_java+/toolchains/platformclasspath_classes; 1s disk-cache, processwrapper-sandbox
Analyzing: target //:license-check (199 packages loaded, 5722 targets configured)
[15 / 17] JavaToolchainCompileBootClasspath external/rules_java+/toolchains/platformclasspath.jar; 0s disk-cache, processwrapper-sandbox
Analyzing: target //:license-check (199 packages loaded, 5722 targets configured)
[16 / 17] Building license.check.license_check.jar (); 0s disk-cache, multiplex-worker
Analyzing: target //:license-check (199 packages loaded, 5722 targets configured)
[17 / 17] no actions running
Analyzing: target //:license-check (200 packages loaded, 10056 targets configured)
[17 / 17] no actions running
Analyzing: target //:license-check (200 packages loaded, 10056 targets configured)
[17 / 17] no actions running
Analyzing: target //:license-check (200 packages loaded, 10056 targets configured)
[17 / 17] no actions running
Analyzing: target //:license-check (200 packages loaded, 10056 targets configured)
[17 / 17] no actions running
Analyzing: target //:license-check (200 packages loaded, 10056 targets configured)
[17 / 17] no actions running
Analyzing: target //:license-check (200 packages loaded, 10056 targets configured)
[17 / 17] no actions running
Analyzing: target //:license-check (200 packages loaded, 10056 targets configured)
[17 / 17] no actions running
INFO: Analyzed target //:license-check (202 packages loaded, 10170 targets configured).
INFO: Found 1 target...
Target //:license.check.license_check up-to-date:
  bazel-bin/license.check.license_check
  bazel-bin/license.check.license_check.jar
INFO: Elapsed time: 43.805s, Critical Path: 3.72s
INFO: 17 processes: 12 internal, 4 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 17 total actions
INFO: Running command line: bazel-bin/license.check.license_check ./formatted.txt <args omitted>
usage: org.eclipse.dash.licenses.cli.Main [-batch <int>] [-cd <url>]
       [-confidence <int>] [-ef <url>] [-excludeSources <sources>] [-help] [-lic
       <url>] [-project <shortname>] [-repo <url>] [-review] [-summary <file>]
       [-timeout <seconds>] [-token <token>]

@github-actions
Copy link
Copy Markdown

The created documentation from the pull request is available at: docu-html

@arkjedrz arkjedrz self-requested a review March 12, 2026 13:37
Copy link
Copy Markdown
Contributor

@arkjedrz arkjedrz left a comment

Choose a reason for hiding this comment

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

Overall LGTM, small issues observed.

/* Helper: write data to a file and ensure it reaches physical storage.*/
score::ResultBlank Kvs::write_and_sync(const std::string& path, const void* data, std::size_t size)
{
auto file_deleter = [](std::FILE* f) {
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.

Is this actually a deleter? This looks more like FILE cleanup.

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.

From the point of view of a smart pointer (std::unique_ptr in this case) it is a deleter as it frees memory resources (through fclose) when the smart pointer ends its life when exiting the scope according to the RAII paradigm.

return score::MakeUnexpected(ErrorCode::PhysicalStorageFailure);
}

/* Flush the C library buffer to the OS. */
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.

Is it a "flush of a C library buffer", or "flush buffer to the OS using C library"? Why mention C library at all?

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 it's better "flush the buffer to the OS" without mentioning the C library. I'll push a fix.

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.

3 participants