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

[Backports stable/1.3] Preallocate segment files #9778

Merged
merged 11 commits into from
Jul 13, 2022

Conversation

npepinpe
Copy link
Member

Description

Backports #9731 to 1.3.x.

Related issues

closes #6504
closes #8099

Definition of Done

Not all items need to be done depending on the issue and the pull request.

Code changes:

  • The changes are backwards compatibility with previous versions
  • If it fixes a bug then PRs are created to backport the fix to the last two minor versions. You can trigger a backport by assigning labels (e.g. backport stable/1.3) to the PR, in case that fails you need to create backports manually.

Testing:

  • There are unit/integration tests that verify all acceptance criterias of the issue
  • New tests are written to ensure backwards compatibility with further versions
  • The behavior is tested manually
  • The change has been verified by a QA run
  • The impact of the changes is verified by a benchmark

Documentation:

  • The documentation is updated (e.g. BPMN reference, configuration, examples, get-started guides, etc.)
  • New content is added to the release announcement
  • If the PR changes how BPMN processes are validated (e.g. support new BPMN element) then the Camunda modeling team should be informed to adjust the BPMN linting.

Please refer to our review guidelines.

Adds a method to preallocate a new file of the expected length,
effectively reserving the disk space for later use. The current
implementation is a "dumb" one, which simply writes 4KB blocks of 0s
until the expected length is reached (meaning the size may be up to 4KB
- 1 byte greater than the desired length, which is acceptable for our
  use case).

While potentially slow, this is not in a hot path, and will be later
optimized with a native syscall to fallocate.
Adds basic tests for `FileUtil#preallocate`. A new dependency was added,
`jnr-posix`, which allows us to check the actual size on disk of the
file in UNIX systems. This gives us the accurate number of blocks
reserved for the file, on disk, even on file systems with compression or
sparse files (i.e. most modern Linux systems), and also ensures that we
don't only read the metadata (e.g. what `Files.size` returns) but really
guarantee we reserved the disk space.
Allows preallocating segment files if configured to do so. On segment
creation, we now preallocate the segment file by default before using
it. If it already existed (but was unused by the log so far), we take
the easy way out and simply delete/recreate it instead of attempting to
grow/shrink it.
Add a new dependency on `jnr-posix` to accurately get the size of the
file on disk. This is necessary to avoid tests passing if we only change
the file's metadata - for example, when mmap-ing a file with a mapping
of length X, then the file will report it has a length of X, even though
it has possibly only one block allocated on disk.
@npepinpe
Copy link
Member Author

I essentially just backported #9777 here, so if you review one of the two, they're pretty much the same.

Copy link
Member

@lenaschoenburg lenaschoenburg left a comment

Choose a reason for hiding this comment

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

👍

@npepinpe
Copy link
Member Author

bors merge

@zeebe-bors-camunda zeebe-bors-camunda bot merged commit a5ecfb7 into stable/1.3 Jul 13, 2022
@zeebe-bors-camunda zeebe-bors-camunda bot deleted the backport-9731-to-stable/1.3 branch July 13, 2022 14:17
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.

None yet

2 participants