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

Global order writer: don't try to delete the current fragment if it had failed to be created. #4052

Merged
merged 2 commits into from
Oct 5, 2023

Conversation

teo-tsirpanis
Copy link
Member

If during a global order write we fail to create a fragment directory, we throw and GlobalOrderWriter::clean_up tries to delete the new fragment. But because we had not yet assigned a URI to a fragment, we try to delete the empty string and get an Error: Unsupported URI scheme: on Unix and Error: Failed to delete path ''; not a valid path. on Windows, masking the real issue.

This PR modifies clean_up to not delete the directory if it is empty, allowing the right error to surface. It's a bit hacky - ideally FragmentMetadata would be C.41 compliant and an empty URI would not be possible, but that would require more extensive refactorings and delay the bug fix. The other writers are not susceptible to this bug; they write only one fragment and their clean-up logic is simpler and takes care of that.

Fixes #4041.

SC-27681

Verified on my machine that the right error message is displayed.


TYPE: BUG
DESC: Global order writer: don't try to delete the current fragment if it had failed to be created.

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #27681: Clearly expose write-permissions failure.

Copy link
Member

@KiterLuc KiterLuc left a comment

Choose a reason for hiding this comment

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

I'd like to see a unit test for this hopefully replicating an access denied, but if it's just a directory that doesn't exist, that should be fine. The unit test should validate that the thrown exception text contains the right message. The test should hit all writers.

Copy link
Contributor

@robertbindar robertbindar left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @teo-tsirpanis, I do agree with you that FragmentMetadata should do creation-deletion of resources on disk, but this doesn't mean your solution here is hacky.
I like Luc's idea of adding an access denied test to cover this, but I'm ok without one as well if it turns out to be very complicated to do.

const auto& uri = global_write_state_->frag_meta_->fragment_uri();

// Cleanup the fragment we are currently writing. There is a chance that the
// URI is empty if creating the first fragment had failed.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/first/latest, failure can happen later in the write process as well, it only happens that a permissions issue triggers a failure on the first fragment write.

Copy link
Contributor

@shaunrd0 shaunrd0 left a comment

Choose a reason for hiding this comment

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

+1 for adding a test, but LGTM 👍

@KiterLuc KiterLuc closed this Oct 5, 2023
@KiterLuc KiterLuc reopened this Oct 5, 2023
@KiterLuc KiterLuc dismissed their stale review October 5, 2023 16:19

Filed a shortcut story to add a test later.

@KiterLuc KiterLuc merged commit d497fff into TileDB-Inc:dev Oct 5, 2023
52 checks passed
@teo-tsirpanis teo-tsirpanis deleted the global-writer-fix branch October 6, 2023 11:10
KiterLuc pushed a commit that referenced this pull request Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clearly expose write-permissions failure
5 participants