Skip to content

Conversation

@duyhuynhdev
Copy link

Fix error alert on prod objectfs

Copy link
Contributor

@bwalkerl bwalkerl left a comment

Choose a reason for hiding this comment

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

Thanks @duyhuynhdev

This commit is fixing a handful of different issues, some of which are mostly unrelated. Can we please split this into separate commits with descriptive commit messages?

Something like:

  • Ensure locks are released properly
  • Add fallback check for directories created between calls

As we don't have an issue raised for these it would also be worth explaining why these are a problem.

// Permission trouble.
throw new file_exception('storedfilecannotcreatefiledirs');
}
if (!is_dir($localdirpath) && !@mkdir($localdirpath, $this->dirpermissions, true) && !is_dir($localdirpath)) {
Copy link
Contributor

@bwalkerl bwalkerl Aug 26, 2025

Choose a reason for hiding this comment

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

Do we really want to suppress mkdir errors? My gut feel is this should still logged, especially when an exception is thrown. Would also recommend leaving a comment as to why we have the second check.

Also do we know what is creating a directory between calls? Is this something making a directory without a lock or a lock not working? This looks correct to me, but I'm a bit concerned if there can be other conflicts later then the fix could potentially be worse than the current issue.

Copy link
Author

Choose a reason for hiding this comment

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

@bwalkerl , I did some research and found this is the common practice for this scenario. If you search for @mkdir, you’ll see the is_dir → @mkdir → is_dir pattern used widely, including in core. That’s why I used @, though I agree it’s risky. On PHP < 8.0 it can suppress critical errors. So I will remove it in the next commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

More than anything the reason we want the warnings is because we don't know what else is creating them, and that's the biggest worry, especially since this function should have a lock.

Copy link
Contributor

Choose a reason for hiding this comment

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

get_contentdir_from_hash returns the comon hash prefix, so two processes could be working on 2 files with their own locks but by chance still have a common prefix and thats fine

@duyhuynhdev duyhuynhdev force-pushed the error-alert-on-prod-wr-465277 branch 2 times, most recently from 47d4703 to 4b78f63 Compare August 27, 2025 00:36
@brendanheywood
Copy link
Contributor

Just muddying the waters slightly at this one got merged which fixes some of the same bits:

#707

@duyhuynhdev will rebase this and remove the duplicate bits and we'll re-review shortly

@duyhuynhdev duyhuynhdev force-pushed the error-alert-on-prod-wr-465277 branch from 3e30754 to b94830a Compare October 23, 2025 02:42
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.

4 participants