Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): add --max-fetch-concurrency to prevent stalled validators #7450

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

ricokahler
Copy link
Contributor

Description

This PR addresses an issue where the sanity documents validate CLI command times out for complex validation rules. The problem occurs when a set of documents with custom validators requires more concurrent client.fetch requests than the current hard-coded limit allows, potentially causing the validation process to block indefinitely.

Changes introduced:

  1. Increased the default maximum fetch concurrency from 10 to 25.
  2. Made the maximum fetch concurrency configurable via a new CLI flag --max-fetch-concurrency.
  3. Made the default maximum custom validation concurrency explicit and configurable.

These changes aim to prevent situations where the validation process exhausts the available concurrent requests, leading to timeouts.

Related issue: SDX-1617

What to review

  1. Review the changes in validateAction.ts, validateDocuments.ts, and validateDocument.ts to ensure the new maxFetchConcurrency option is correctly implemented and passed through the validation process.
  2. Check the updated validateDocumentsCommand.ts to confirm the new --max-fetch-concurrency CLI flag is properly documented.
  3. Verify that the default values for both maxCustomValidationConcurrency and maxFetchConcurrency are set correctly (5 and 25, respectively).
  4. Ensure that the concurrency limiter is created with the new configurable maximum fetch concurrency.

Testing

To test these changes:

  1. Run the sanity documents validate command on a dataset with complex validation rules that previously timed out.
  2. Try different values for --max-fetch-concurrency to ensure it affects the validation process as expected.
  3. Verify that setting a lower --max-custom-validation-concurrency value doesn't cause timeouts when combined with the increased fetch concurrency.

I manually tested these changes by running a reproduction locally using the dataset and repo provided by Ken Jones (see slack thread attached to the ticket). With the increased fetch concurrency limit of 25, the validation process completed successfully without timeouts, confirming that the changes resolve the issue in this specific case.

Additional automated tests should be added to verify the behavior of the new concurrency settings.

Notes for release

This update addresses an issue where the sanity documents validate CLI command could time out when validating documents with complex custom validation rules. The changes include:

  1. Increased default maximum fetch concurrency from 10 to 25, which should resolve most timeout issues.
  2. Added a new CLI flag --max-fetch-concurrency to allow users to adjust the maximum number of concurrent client.fetch requests during validation.
  3. Made the default maximum custom validation concurrency explicit and configurable.

Usage:

sanity documents validate --max-fetch-concurrency <number>

These changes should improve the performance and reliability of document validation for projects with complex custom validation rules. Users experiencing timeouts during validation should try increasing the --max-fetch-concurrency value if issues persist with the new default.

@ricokahler ricokahler requested a review from a team as a code owner August 30, 2024 15:01
@ricokahler ricokahler requested review from cngonzalez and removed request for a team August 30, 2024 15:01
Copy link

vercel bot commented Aug 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 30, 2024 3:14pm
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 30, 2024 3:14pm
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 30, 2024 3:14pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 30, 2024 3:14pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 30, 2024 3:14pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Aug 30, 2024 3:14pm

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Aug 30, 2024

Component Testing Report Updated Aug 30, 2024 3:18 PM (UTC)

✅ All Tests Passed -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 44s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 9s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 31s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 39s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 19s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 3m 0s 0 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 46s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 47s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 17s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 9s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 28s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 19s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 37s 12 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

Copy link
Member

@cngonzalez cngonzalez left a comment

Choose a reason for hiding this comment

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

gave it a quick read but it makes sense to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants