flyte icon indicating copy to clipboard operation
flyte copied to clipboard

[BUG] v2: run-level overwrite_cache is ignored, cached tasks still hit

Open mitja-kleider opened this issue 1 week ago • 1 comments

Describe the bug

flyte.with_runcontext(overwrite_cache=True).run(...) sets RunSpec.overwrite_cache and RunSpec.cache_config.overwrite_cache, but the v2 backend never reads either. A cached task in such a run still gets a cache hit, and a serialized one still waits on another run's reservation.

Neither field is read anywhere outside gen/ on main (6fc4786d8):

  • applyRunSpecToTaskAction (actions/k8s/client.go) projects env vars, interruptible, pod template, service account and raw data prefix into the TaskActionSpec, but not the overwrite flag, and TaskActionSpec has no field for it.
  • evaluateCacheBeforeExecution (executor/pkg/controller/taskaction_cache.go) always calls Catalog.Get and, for serializable tasks, GetOrExtendReservation.
  • writeTaskOutputsToCache always calls Catalog.Put, which keeps an existing entry, although the cache service client already has Update (Put with overwrite: true).

Expected behavior

As in v1 propeller (nodes/executor.go, nodes/cache.go): with the overwrite flag on, a cacheable task skips the lookup (CACHE_SKIPPED), skips the serialization reservation, runs, and writes its outputs with Update, replacing the cached entry.

How to reproduce

import flyte

env = flyte.TaskEnvironment("overwrite-repro")

@env.task(cache=flyte.Cache(behavior="override", version_override="1"))
async def now() -> str:
    import datetime
    return datetime.datetime.now().isoformat()

flyte.init_from_config()
first = flyte.run(now)
first.wait()
second = flyte.with_runcontext(overwrite_cache=True).run(now)
second.wait()
# Expected: second runs and returns a new timestamp. Actual: cache hit, same timestamp.

Proposed fix

  1. TaskActionSpec.OverwriteCache bool, set in applyRunSpecToTaskAction from RunSpec.overwrite_cache || RunSpec.cache_config.overwrite_cache and copied in inheritRunContextFromParentTaskAction, so child actions get it too.
  2. In taskaction_cache.go, carry it in taskCacheConfig: skip the lookup and the reservation (also in maintainCacheReservation), and write with Catalog.Update instead of Put.

Environment

Flyte v2.0.55 (self-hosted), flyte SDK 2.13.4.

mitja-kleider avatar Nov 20 '26 08:11 mitja-kleider

The documented behavior matches your expected result: overwrite_cache=True should re-execute tasks and replace cached results. The provided sources don’t verify whether the v2 backend currently honors this flag or confirm the proposed code changes. Run context

Would you like more detail?

Sources:


This is an AI-generated response and your feedback is appreciated! Please leave a 👍 if this is helpful and 👎 if it is not.

Mention @herald to ask follow-up questions. See runllm.com for more!

runllm avatar Nov 20 '26 08:11 runllm