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

Fix metadata storage with sharding #48563

Merged
merged 2 commits into from
Nov 7, 2024
Merged

Fix metadata storage with sharding #48563

merged 2 commits into from
Nov 7, 2024

Conversation

icewind1991
Copy link
Member

And add the most minimal set of tests to ensure this keeps working.

The way of passing the storage id to the db code is a bit iffy. But I didn't want to change any public interface

@icewind1991 icewind1991 added the 3. to review Waiting for reviews label Oct 3, 2024
@icewind1991 icewind1991 added this to the Nextcloud 31 milestone Oct 3, 2024
try {
/** @var FilesMetadata $metadata */
Copy link
Contributor

Choose a reason for hiding this comment

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

Typing is not working?

Copy link
Member Author

Choose a reason for hiding this comment

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

Things are typed to return this interface, but only the implementation has the setStorageId method because I didn't want to touch the public api

Comment on lines +35 to +39
// all code paths that lead to saving metadata *should* have the storage id set
// this fallback is there just in case
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll need to update applications like Photos

$query->select('storage')
->from('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($filesMetadata->getFileId(), IQueryBuilder::PARAM_INT)));
return $query->executeQuery()->fetchColumn();
Copy link
Contributor

@artonge artonge Oct 3, 2024

Choose a reason for hiding this comment

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

Wondering if we should cache it with $filesMetadata->setStorageId(), but I don't think that we have scenarios where we are saving the same metadata object multiple times.

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems unlikely yes, but might as well

@icewind1991 icewind1991 force-pushed the metadata-storage-id branch 2 times, most recently from 241c22d to 46a889c Compare October 4, 2024 15:23
@icewind1991 icewind1991 requested review from a team, Altahrim and sorbaugh and removed request for a team October 8, 2024 17:05
Copy link
Member

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

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

LGTM, just psalm is unhappy.

@icewind1991 icewind1991 merged commit 6fa4266 into master Nov 7, 2024
177 checks passed
@icewind1991 icewind1991 deleted the metadata-storage-id branch November 7, 2024 17:20
@icewind1991
Copy link
Member Author

/backport to stable30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants