Skip to content

fix: include Query field in CDC lazy recovery nar.URL - #1095

Merged
kalbasit merged 1 commit into
mainfrom
fix-include-query-field-in-cdc
Mar 16, 2026
Merged

kalbasit merged 1 commit into
mainfrom
fix-include-query-field-in-cdc

Conversation

@kalbasit

@kalbasit kalbasit commented Mar 16, 2026 •

Copy link
Copy Markdown
Owner

The CDC lazy chunking recovery cron job was failing to recover stuck NAR files because it wasn't passing the Query field when constructing nar.URL. This caused BackgroundMigrateNarToChunks to not find the stuck record (which has a query string like ?fakesize=123), and instead incorrectly fall back to finding a DIFFERENT record that's already chunked, resulting in 'nar already chunked' errors.

The fix parses the Query string from the database record and includes it in the nar.URL structure passed to BackgroundMigrateNarToChunks.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 16, 2026
@kalbasit

kalbasit commented Mar 16, 2026 •

Copy link
Copy Markdown
Owner Author

This change is part of the following stack:

Change managed by git-spice.

@dosubot dosubot Bot added bug Something isn't working go Pull requests that update go code labels Mar 16, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical issue in the CDC lazy chunking recovery process where stuck NAR files were not being correctly recovered. The problem stemmed from the Query field being omitted during the construction of nar.URL objects, which led to misidentification of records and subsequent recovery failures. The changes ensure that the Query string is now properly parsed and incorporated into the nar.URL, enabling accurate and successful recovery of these files.

Highlights

  • Fix CDC Lazy Recovery: The CDC lazy chunking recovery cron job was failing to recover stuck NAR files because it did not include the Query field when constructing nar.URL.
  • Incorrect Record Identification: The absence of the Query field caused BackgroundMigrateNarToChunks to incorrectly fall back to finding an already chunked record, leading to 'nar already chunked' errors.
  • Solution Implemented: The fix involves parsing the Query string from the database record and including it in the nar.URL structure passed to BackgroundMigrateNarToChunks.
Changelog
  • charts/ncps/templates/configmap.yaml
    • Ensured delete-delay and lazy-recovery-schedule values are explicitly quoted in the Helm chart configuration.
  • dev-scripts/run.py
    • Added default values for cache-cdc-lazy-recovery-schedule and cache-cdc-delete-delay to the application command arguments for development environments.
  • pkg/cache/cache.go
    • Implemented parsing of the Query string from stuckFile.Query.
    • Included the parsed Query in the nar.URL structure during CDC lazy recovery.
    • Added error logging for cases where the query string fails to parse.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@dosubot

dosubot Bot commented Mar 16, 2026 •

Copy link
Copy Markdown

Documentation Updates

1 document(s) were updated by changes in this PR:

Cache and Storage Configuration Flags
View Changes
@@ -212,8 +212,8 @@
 - `--cache-cdc-lazy-recovery-schedule` (string): Cron schedule for recovering stuck NARs in lazy chunking mode. Default: `@every 5m`
   - Environment variable: `CACHE_CDC_LAZY_RECOVERY_SCHEDULE`
   - YAML key: `cache.cdc.lazy-recovery-schedule`
-  - Helm value: `config.cdc.lazyRecoverySchedule`
-  - Purpose: Controls the schedule for a background recovery mechanism that automatically re-triggers chunking for NARs that became stuck when ncps restarted before background chunking completed. Accepts `@every X` format (e.g., `@every 5m`, `@every 10m`) or standard cron expressions. This job uses distributed locking to prevent duplicate processing across instances.
+  - Helm value: `config.cdc.lazyRecoverySchedule` (should be properly quoted in YAML configurations)
+  - Purpose: Controls the schedule for a background recovery mechanism that automatically re-triggers chunking for NARs that became stuck when ncps restarted before background chunking completed. The recovery process correctly handles NAR records that include query string parameters (such as `?fakesize=123`) by parsing and including the Query field from the database record. Accepts `@every X` format (e.g., `@every 5m`, `@every 10m`) or standard cron expressions. This job uses distributed locking to prevent duplicate processing across instances.
 
 - `--cache-cdc-lazy-recovery-batch-size` (integer): Maximum number of stuck NARs to process per recovery cron run. Default: `100`
   - Environment variable: `CACHE_CDC_LAZY_RECOVERY_BATCH_SIZE`

How did I do? Any feedback?  Join Discord

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a bug in the CDC lazy recovery cron job where the Query field was missing from the nar.URL for stuck NAR files, causing lookup failures. The main change in pkg/cache/cache.go correctly parses the query string from the database and populates the nar.URL. Supporting changes include adding quoting to string values in the Helm chart for robustness and setting default CDC recovery flags in the development script. The changes appear correct and effectively resolve the described issue.

The CDC lazy chunking recovery cron job was failing to recover stuck NAR
files because it wasn't passing the Query field when constructing
nar.URL. This caused BackgroundMigrateNarToChunks to not find the stuck
record (which has a query string like ?fakesize=123), and instead
incorrectly fall back to finding a DIFFERENT record that's already
chunked, resulting in 'nar already chunked' errors.

The fix parses the Query string from the database record and includes it
in the nar.URL structure passed to BackgroundMigrateNarToChunks.
@kalbasit
kalbasit force-pushed the fix-include-query-field-in-cdc branch from 1acc555 to 311efcb Compare March 16, 2026 06:06
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Mar 16, 2026
@codecov

codecov Bot commented Mar 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 5.04%. Comparing base (e73aee7) to head (311efcb).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1095   +/-   ##
=====================================
  Coverage   5.04%   5.04%           
=====================================
  Files          6       6           
  Lines        436     436           
=====================================
  Hits          22      22           
  Misses       410     410           
  Partials       4       4           

☔ View full report in Codecov by Sentry.
📢 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.

@kalbasit
kalbasit merged commit 40d20c9 into main Mar 16, 2026
18 checks passed
@kalbasit
kalbasit deleted the fix-include-query-field-in-cdc branch March 16, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant