<#7495 fix(flytestdlib): mark batch head item as p...
# flyte-github
a
#7495 fix(flytestdlib): mark batch head item as processing in auto-refresh cache Pull request opened by 1fanwang Why are the changes needed? The auto-refresh cache tracks which items a worker is currently syncing so the periodic resync does not enqueue an item again while it is still in flight. The first item of every enqueued batch was never recorded as in-flight, so the resync loop kept re-enqueueing items that were already being synced — the same key handled by multiple workers at once, duplicate
syncCb
calls, and wasted workqueue throughput. With the default single-item batching this affects every item the cache tracks. What changes were proposed in this pull request? Record every item in an enqueued batch as in-flight, including the first one. How was this patch tested? Added
TestEnqueueBatches_MarksSingleItemBatchHead
to both
flytestdlib/cache
and
flytestdlib/autorefreshcache
. It drives the real enqueue path with the default single-item batching and asserts the enqueued item is marked in-flight. Reproduce:
Copy code
go test ./flytestdlib/cache/ ./flytestdlib/autorefreshcache/ -run TestEnqueueBatches_MarksSingleItemBatchHead -v
Before:
Copy code
--- FAIL: TestEnqueueBatches_MarksSingleItemBatchHead
    single-item batch head must be marked processing after enqueue
    Should be true
FAIL    github.com/flyteorg/flyte/v2/flytestdlib/cache
--- FAIL: TestEnqueueBatches_MarksSingleItemBatchHead
    single-item batch head must be marked processing after enqueue
    Should be true
FAIL    github.com/flyteorg/flyte/v2/flytestdlib/autorefreshcache
After:
Copy code
--- PASS: TestEnqueueBatches_MarksSingleItemBatchHead
ok      github.com/flyteorg/flyte/v2/flytestdlib/cache
--- PASS: TestEnqueueBatches_MarksSingleItemBatchHead
ok      github.com/flyteorg/flyte/v2/flytestdlib/autorefreshcache
Both packages also pass with
-race
. Labels fixed Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. flyteorg/flyte