Page MenuHomePhabricator

[services] Backup - consider index for BackupItem
AbandonedPublic

Authored by karol on Mar 31 2022, 6:31 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 23, 11:25 PM
Unknown Object (File)
Sun, Oct 13, 4:17 PM
Unknown Object (File)
Sun, Oct 13, 4:17 PM
Unknown Object (File)
Sun, Oct 13, 4:14 PM
Unknown Object (File)
Sep 23 2024, 12:18 PM
Unknown Object (File)
Sep 13 2024, 3:18 AM
Unknown Object (File)
Sep 3 2024, 12:28 PM
Unknown Object (File)
Sep 3 2024, 12:27 PM

Details

Summary

Depends on D3583

For every index we use, we should consider fetching a custom set of fields from the database based on what this index projects.

I tried to do it in a couple of different ways, for example with enum/classes/inheritance + the second argument to the assignItemFromDatabase with a default value but all in all, this turned out to be the cleanest way.

Test Plan
cd services
yarn run-backup-service

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

tomek requested changes to this revision.Apr 6 2022, 11:53 PM

It looks like the only difference comparing to assignItemFromDatabase is that we're not setting compactionHolder and attachmentsHolders. In assignItemFromDatabase we check if these are set in itemFromDB and if not, we don't assign them.
Why do we need a method which skips this? Does itemFromDB in assignItemFromDatabaseUserIDCreatedIndex have attachmentsHolders and assignItemFromDatabase set? If not, then the original method should work just fine.

Could you explain what you mean by

For every index we use, we should consider fetching a custom set of fields from the database based on what this index projects.

It doesn't look like this code does what you described. We read the data from AttributeValues which has nothing to do with fetching. Please be more precise.

This revision now requires changes to proceed.Apr 6 2022, 11:53 PM

The original idea was to create a method for every index. An index is a copy of an original table that projects (contains) a subset of fields of the original table (it may also contain the same set of fields).
Honestly, here this is just a coincidence that the method assignItemFromDatabase is going to work for this index and assignItemFromDatabaseUserIDCreatedIndex is redundant.

As for "fetching" - yes, ok, your nit is valid here - it's not about fetching as the data is already fetched, it's about what we pull from that fetched data and insert into BackupItem; in other words, which fields exactly we use while casting from AttributeValues into BackupItem (also, by "fields", I meant "attributes" IIRC, if we want to strictly stick to the dynamo's naming).

I think we can abandon here and use assignItemFromDatabase. Nevertheless, the idea from this diff is probably going to be useful someday.