Skip to content

fix: Clear stale negative cache entries#4328

Draft
jjerphan wants to merge 5 commits into
mamba-org:mainfrom
jjerphan:fix/clear-negative-cache-entries
Draft

fix: Clear stale negative cache entries#4328
jjerphan wants to merge 5 commits into
mamba-org:mainfrom
jjerphan:fix/clear-negative-cache-entries

Conversation

@jjerphan

@jjerphan jjerphan commented Jun 22, 2026

Copy link
Copy Markdown
Member

Description

Tentative fix for #4322.

Fix failures observed in Code Coverage workflows.

Type of Change

  • Bugfix
  • Feature / enhancement
  • CI / Documentation
  • Maintenance

Checklist

  • My code follows the general style and conventions of the codebase, ensuring consistency
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run pre-commit run --all locally in the source folder and confirmed that there are no linter errors.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

@github-actions github-actions Bot added the release::bug_fixes For PRs fixing bugs label Jun 22, 2026
@jjerphan jjerphan mentioned this pull request Jun 22, 2026
11 tasks
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 54.71698% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.95%. Comparing base (6bf836f) to head (1659911).

Files with missing lines Patch % Lines
libmamba/src/core/transaction.cpp 0.00% 24 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4328      +/-   ##
==========================================
+ Coverage   55.08%   55.95%   +0.86%     
==========================================
  Files         240      240              
  Lines       30329    30375      +46     
  Branches     3241     3250       +9     
==========================================
+ Hits        16707    16995     +288     
+ Misses      13619    13377     -242     
  Partials        3        3              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jjerphan jjerphan marked this pull request as ready for review June 22, 2026 11:35
void update_monitor(progress_callback_t* cb, PackageExtractEvent event) const;

specs::PackageInfo m_package_info;
MultiPackageCache* m_caches = nullptr;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm is this a leftover? It doesn't seem to be used and I'm not sure I understand why it would be needed.

@jjerphan jjerphan Jun 22, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MultiPackageCache is actually used via the PackageFetchers (see their instantiations bellow).

Comment on lines +36 to +68
struct ScopedContextOverride
{
ScopedContextOverride(Context& ctx, const fs::u8path& prefix, const fs::u8path& pkgs_dir)
{
m_ctx = &ctx;
m_saved_prefix_params = ctx.prefix_params;
m_saved_pkgs_dirs = ctx.pkgs_dirs;
m_saved_prefix_data_interoperability = ctx.prefix_data_interoperability;
m_saved_extract_threads = ctx.threads_params.extract_threads;

ctx.prefix_params.target_prefix = prefix;
ctx.prefix_params.root_prefix = prefix;
ctx.prefix_params.conda_prefix = prefix;
ctx.prefix_params.relocate_prefix = prefix;
ctx.pkgs_dirs = { pkgs_dir };
ctx.prefix_data_interoperability = false;
ctx.threads_params.extract_threads = 1;
}

~ScopedContextOverride()
{
m_ctx->prefix_params = m_saved_prefix_params;
m_ctx->pkgs_dirs = m_saved_pkgs_dirs;
m_ctx->prefix_data_interoperability = m_saved_prefix_data_interoperability;
m_ctx->threads_params.extract_threads = m_saved_extract_threads;
}

Context* m_ctx = nullptr;
PrefixParams m_saved_prefix_params;
std::vector<fs::u8path> m_saved_pkgs_dirs;
bool m_saved_prefix_data_interoperability = false;
int m_saved_extract_threads = 0;
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems overrated and doesn't seem to be used either (unused declared context_guard).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constructor and the destructor of ScopedContextOverride are handling the logic of the interaction with the context guaranteeing that the state will be the original one when the scope change.

So context_guard is declared (also defined) unused by any other instructions, yet not useless.

We have this pattern at several places in tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this pattern at several places in tests.

In that case, we may want to consider having a global common struct for all tests instead of rewriting it in each test (even if not all parameters are involved each time).
To be evaluated...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose #4334.

@jjerphan jjerphan force-pushed the fix/clear-negative-cache-entries branch from 67b4f4c to 1485058 Compare June 22, 2026 16:22
@jjerphan jjerphan marked this pull request as draft June 23, 2026 09:31
Comment thread libmamba/include/mamba/core/package_fetcher.hpp Outdated
@jjerphan jjerphan force-pushed the fix/clear-negative-cache-entries branch from fc32cc4 to 1659911 Compare July 1, 2026 11:44
jjerphan and others added 5 commits July 1, 2026 13:44
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>

Co-authored-by: Johan Mabille <johan.mabille@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release::bug_fixes For PRs fixing bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants