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

Possible duplicates in the decision table #522

Open
ColinHebert opened this issue Oct 14, 2023 · 0 comments
Open

Possible duplicates in the decision table #522

ColinHebert opened this issue Oct 14, 2023 · 0 comments
Labels
bug Something isn't working logging search Related to search

Comments

@ColinHebert
Copy link
Contributor

ColinHebert commented Oct 14, 2023

The current logic behind the decision caching system assumes that there should be only one entry per searchee_id/guid pair in the decision table https://github.com/cross-seed/cross-seed/blob/master/src/decide.ts#L215-L224

The database setup though does not accomodate for that: https://github.com/cross-seed/cross-seed/blob/master/src/migrations/00-initialSchema.ts#L12

To ensure true uniqueness of searchee_id/guid in decision, the following should be added to the table:

table.unique(['searchee_id', 'guid'])

This change can't be made without doing some cleanup ahead of time though, as there are likely "duplicate" entries in the existing decision table. So a migration script, which probably should remove all decisions but the last ones in case of duplicates, will be necessary.


In addition to the table constraints themselves, the logic of decision creation relies on calls to assessAndSaveResults (not exported) https://github.com/cross-seed/cross-seed/blob/master/src/decide.ts#L185-L203 which may happen multiple times.

A more elegant way of handling it would be for assessCandidateCaching (exported as assessCandidate) to "attempt to create a decision" ahead of time (with dummy values), and make the necessary updates when needed. This would be akin to https://github.com/cross-seed/cross-seed/blob/master/src/pipeline.ts#L75-L79 which attempts to create a searchee ahead of time to ensure a unique Id is available for follow up operations.

Discussion on discord: https://discord.com/channels/880949701845872672/880949702349164556/1162863467129225257

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working logging search Related to search
Projects
None yet
Development

No branches or pull requests

2 participants