JetBrains / teamcity-azure-storage

TeamCity Azure artifacts storage support plugin
Apache License 2.0
15 stars 7 forks source link

The link cache hangs on to the SAS urls too long #13

Closed droyad closed 3 years ago

droyad commented 3 years ago

The myLinksCache expires items after urlLifeTime. The Azure URLs are generated using that exact same duration. The default is 60 seconds.

The overall process is:

  1. Calculate the link expiry date
  2. Request a URL for that expiry date
  3. Add the URL to the cache
  4. [Just under 60 seconds passes]
  5. Another build needs the link
  6. The link is in the cache, that link is returned
  7. The link is used to download the file

The time between step 1 and 3, and step 6 and 7 is non-zero. Therefore the cache can return a link that is almost expired or has expired very recently.

My suggestion is that the url expiry is twice that of the cache time. A cache time of 60 seconds seems reasonable.

IlyaFomenko commented 3 years ago

@droyad It was not a trivial problem. Thank you for your investigation! I added a separate internal property for configuring the max-age for http cache. By default it is twice shorter than the link expiration time. Please see https://github.com/JetBrains/teamcity-azure-storage/commit/092e8645666620329a15a406cebde0d95f9159df

matt-richardson commented 2 years ago

Unfortunately, this issue is still occurring :(

droyad commented 2 years ago

@IlyaFomenko I think there is a still a problem as the myLinksCache still hangs onto the URL for the exact time it is valid for. I've created a new PR #15 with a suggested fix.