-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: use etags for caching to avoid backend/db load when idle #2731
Conversation
f71254b
to
d11a39b
Compare
Ideas from pair programming: We can use this with the http header with Update silo_import_job.sh to first check for changes before getting all released-data |
One issue we have right now is that "current_preprocessing_pipeline" table seems to be updated without any real changes. It still shows this:
We either have to make the trigger function smarter to only trigger on actual changes (not just update commands that don't cause changes) - or we use that timestamp from that table directly instead of the "last update" table. |
Same with the Probably for now, in the version table we can look up the timestamp directly. And we might be able to ignore the preprocessed data table entirely. |
backend/src/main/resources/db/migration/V1.2__add_table_update_tracker.sql
Show resolved
Hide resolved
backend/src/main/resources/db/migration/V1.2__add_table_update_tracker.sql
Show resolved
Hide resolved
backend/src/main/resources/db/migration/V1.2__add_table_update_tracker.sql
Show resolved
Hide resolved
Hmm I wonder if the fact that |
Just looked into this with @chaoran-chen - thanks!
Implemented in 3fe4d5f |
Great! Much easier to get rid of these spurious updates than I feared! What about the continuous updates to |
Woops @anna-parker backend tests now fail: https://github.com/loculus-project/loculus/actions/runs/10790922697/job/29927194807?pr=2731 |
After further investigation the conditional update that chatgpt suggested does not seem to work - causing a database update every 10seconds even when there are no changes, additionally the cleanUpStaleSequencesInProcessing will always perform a delete action on the database every minute even when there is nothing to delete. |
0c3218d
to
c154095
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add a unit test that checks that it works? The new SQL file seems at least medium complex.
backend/src/main/kotlin/org/loculus/backend/service/submission/SubmissionDatabaseService.kt
Outdated
Show resolved
Hide resolved
backend/src/main/kotlin/org/loculus/backend/service/submission/SubmissionDatabaseService.kt
Outdated
Show resolved
Hide resolved
backend/src/main/kotlin/org/loculus/backend/service/submission/SubmissionDatabaseService.kt
Outdated
Show resolved
Hide resolved
backend/src/main/kotlin/org/loculus/backend/controller/SubmissionController.kt
Outdated
Show resolved
Hide resolved
backend/src/main/kotlin/org/loculus/backend/controller/SubmissionController.kt
Outdated
Show resolved
Hide resolved
backend/src/main/kotlin/org/loculus/backend/controller/SubmissionControllerDescriptions.kt
Outdated
Show resolved
Hide resolved
backend/src/main/kotlin/org/loculus/backend/service/submission/SubmissionDatabaseService.kt
Outdated
Show resolved
Hide resolved
...end/src/test/kotlin/org/loculus/backend/controller/submission/GetReleasedDataEndpointTest.kt
Outdated
Show resolved
Hide resolved
...end/src/test/kotlin/org/loculus/backend/controller/submission/GetReleasedDataEndpointTest.kt
Outdated
Show resolved
Hide resolved
backend/src/main/kotlin/org/loculus/backend/controller/SubmissionController.kt
Outdated
Show resolved
Hide resolved
backend/src/main/kotlin/org/loculus/backend/controller/SubmissionController.kt
Show resolved
Hide resolved
This decreases backend/database load (and hence costs) by a lot! As I expected when making #2092 🎉 |
co-authored with @anna-parker and Claude Sonnet
0a61f8b
to
42342c3
Compare
…/UpdateTrackerTable.kt Co-authored-by: Fabian Engelniederhammer <92720311+fengelniederhammer@users.noreply.github.com>
…/UpdateTrackerTable.kt Co-authored-by: Fabian Engelniederhammer <92720311+fengelniederhammer@users.noreply.github.com>
…_tracker.sql Co-authored-by: Fabian Engelniederhammer <92720311+fengelniederhammer@users.noreply.github.com>
backend/src/main/kotlin/org/loculus/backend/controller/SubmissionControllerDescriptions.kt
Outdated
Show resolved
Hide resolved
backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt
Outdated
Show resolved
Hide resolved
backend/src/main/kotlin/org/loculus/backend/service/submission/SubmissionDatabaseService.kt
Outdated
Show resolved
Hide resolved
backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor things left, but looks good 👍
backend/src/main/kotlin/org/loculus/backend/controller/SubmissionController.kt
Show resolved
Hide resolved
backend/src/main/kotlin/org/loculus/backend/service/submission/SubmissionDatabaseService.kt
Outdated
Show resolved
Hide resolved
...end/src/test/kotlin/org/loculus/backend/controller/submission/GetReleasedDataEndpointTest.kt
Outdated
Show resolved
Hide resolved
...end/src/test/kotlin/org/loculus/backend/controller/submission/GetReleasedDataEndpointTest.kt
Show resolved
Hide resolved
…/SubmissionDatabaseService.kt Co-authored-by: Fabian Engelniederhammer <92720311+fengelniederhammer@users.noreply.github.com>
…ion/GetReleasedDataEndpointTest.kt Co-authored-by: Fabian Engelniederhammer <92720311+fengelniederhammer@users.noreply.github.com>
…_DATA_RELATED_TABLES
co-authored with @anna-parker and Claude Sonnet
related to: #2092
preview URL: https://table-update-tracker.loculus.org
Summary
IF_NONE_MATCH
header toget-released-data
, this accepts an etag and returns a lastDatabaseWriteETag corresponding to the lastDatabaseWrite. If the etag and the current lastDatabaseWriteETag differget-released-data
will respond with all released data and the current lastDatabaseWriteETag. If the atg is equal to current lastDatabaseWriteETag thenget-released-data
will respond with 304: NOT_MODIFIED.silo_import_job.sh
andsilo_import_wrapper.sh
to use theIF_NONE_MATCH
header. This significantly reduces the load on the database and backend, times are from after preprocessing has finished (CPU is in mCPU):PR Checklist