Repository navigation
split: create empty chunks deferred by the open files limit - #16738
Open
costajohnt wants to merge 1 commit into
Open
costajohnt wants to merge 1 commit into
costajohnt wants to merge 1 commit into
Conversation
With -n N, -n l/N and -n r/N, output files that could not be opened upfront because of the open files limit were only opened once they received data. Chunks that stayed empty were then never created, or kept stale contents when a prefix was reused. Once input ends, open and close every chunk that was never opened, one at a time, so all chunks exist and are truncated like in GNU split. Fixes uutils#16737
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #16737
With
-n N,-n l/Nand-n r/N,OutFiles::initdefers any output file it can't open because of the open files limit, and a deferred file is only opened once it receives data. When input ran out first, those chunks were never created, or kept their old contents when a prefix was reused, so reassembling the chunks returned bytes from the previous run.Once input ends,
create_unopenednow opens and closes every chunk that was never opened, one at a time, through the existinginstantiate_writer(so it still closes another writer if the limit is hit). All three-nmodes go through the sharedOutFilescode. With-e, the line and round robin modes skip this step, so elided chunks are still not created.The issue's repro under
ulimit -n 12now prints!and leaves 20 files. Before, byte mode printed!JKLMNOPQRST, and the line modes left only 9 of the 20 files.Tests:
test_limited_file_descriptors_truncates_unwritten_chunkscovers20,l/20andr/20under the sameNOFILElimit astest_round_robin_limited_file_descriptors. It checks that a fresh directory gets all 20 empty chunks, and that reusing a prefix with a shorter input reassembles to exactly the new input. It fails on main (missing chunk files) and passes with this change.cargo test --features split test_split, clippy,cargo fmt --checkandcargo docwith-Dwarningspass locally.One related thing I left alone:
instantiate_writertreats any open error as hitting the descriptor limit, so a chunk that can't be created for another reason (for example a directory namedxab) prints the "at file descriptor limit" message before the real error. That already happens on main in the round robin data path, and the reopen path inopen_output_filedrops the OS error, so telling the two apart needs its own change. Happy to send that as a follow-up.