ssl-hep / ServiceX_frontend

Client access library for ServiceX
https://servicex-frontend.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
5 stars 11 forks source link

Cache Collision when the user ignores the cache and hash is present in the db Fix #375 #482

Closed ketan96-m closed 1 month ago

ketan96-m commented 2 months ago

Problem

Resolve #375

cached_record = (
            self.cache.get_transform_by_hash(sx_request_hash)   # this raises exception when 2 records are present
            if not self.ignore_cache
            else None
        )

When the user submits a transform without ignore-cache -> records are inserted as expected When the user submits same transform with ignore-cache -> a NEW record is still created (tiny db has no unique value contraints) When the user submits same tranform without ignore-cache -> 2 records are present hence raises exception

Fix

When the user submits a query and selects ignore_cache - Check if we have a previous hash already present and if present delete that record since we are going to run the transform again.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 83.52%. Comparing base (0487232) to head (97dbb29). Report is 2 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #482 +/- ## ========================================== + Coverage 82.89% 83.52% +0.63% ========================================== Files 26 26 Lines 1397 1451 +54 ========================================== + Hits 1158 1212 +54 Misses 239 239 ``` | [Flag](https://app.codecov.io/gh/ssl-hep/ServiceX_frontend/pull/482/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ssl-hep) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/ssl-hep/ServiceX_frontend/pull/482/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ssl-hep) | `83.52% <100.00%> (+0.63%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ssl-hep#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ponyisi commented 1 month ago

Could you add a test for the specific code path that codecov is complaining about? Then I'll approve

ketan96-m commented 1 month ago

@ponyisi @gordonwatts ready for review The unit tests were a piece to get it working!