René's URL Explorer Experiment


Title: fix(knowledge): give failed documents a grace while their retries are still scheduled by waleedlatif1 · Pull Request #6924 · simstudioai/sim · GitHub

Open Graph Title: fix(knowledge): give failed documents a grace while their retries are still scheduled by waleedlatif1 · Pull Request #6924 · simstudioai/sim

X Title: fix(knowledge): give failed documents a grace while their retries are still scheduled by waleedlatif1 · Pull Request #6924 · simstudioai/sim

Description: Live on staging. Found by an independent audit of the merged connector work — an interaction between #6920 and #6921, each correct alone. The bug The sweep treats failed as terminal, documented as "the run that produced it has ended." That was true when processing ran inline. Since #6920 made dispatch asynchronous: the worker writes processingStatus: 'failed' and then rethrows the Trigger task retries up to maxAttempts (default 3) So between attempts the row reads failed while a live run is scheduled to retry it. The sweep gave failed zero grace, so it reclaimed the document, deleted its embeddings, and re-dispatched with a fresh pass id — two live runs, two indexing passes, two bills. Exactly what #6911 and #6921 exist to prevent, reached through the one state deliberately left unguarded. Backoff between attempts is short, so the window is seconds per document — but it is per document across a 7,730-document corpus, and an OOM-kill reschedule is far longer than the configured backoff. The fix Aged from processingCompletedAt, which every failure write stamps, so it reads exactly when the last attempt ended rather than when the document was dispatched. Sized at the queue grace, not a run-duration bound. This was the one wrong turn available: STALE_PROCESSING_MINUTES bounds a run, but what is being waited on between attempts is a re-queue behind the same global concurrency limit. On a large backlog the next attempt starts hours after the previous one ended, so a 45-minute grace would still reclaim documents mid-retry-chain — just less often, which is the worst kind of fix. The grace is now an expression, not a constant: ceil(LARGEST_OBSERVED_CORPUS / QUEUE_CONCURRENCY × OCCUPANCY × CONTENTION) = ceil(7730 / 20 × 1 × 2) = 773 minutes Each input is documented with where to re-measure it. The previous 240 was derived from a 2,600-document corpus and sat below the drain time of the 7,730-document connector it was written for. Rounding is deliberately up: too small silently re-bills live work; too large only delays recovery of documents nothing is processing. The test pins 773 so changing an input fails loudly rather than being absorbed. Recovery for a genuinely lost dispatch becomes grace + sync interval — free at the 1,440-minute default interval, and still an order of magnitude inside RETRY_WINDOW_DAYS. Also: withdrawing an unearned stamp The queue stamp is written before dispatch, so it records intent rather than fact. That ordering is deliberate and stays — a chunked batch can half-succeed, and stamping after dispatch would strand the documents that genuinely are executing. Before-dispatch fails safe; after-dispatch fails unsafe. But in the total-failure branch we can prove nothing dispatched, so the stamp is withdrawn there before it throws. Scoped three ways: to the batch's own ids, to rows still pending, and by compare-and-set on the exact stamp that call wrote — so a concurrent batch that has already re-stamped a document keeps its grace. The withdrawal is best-effort while the stamp write still throws. Asymmetric on purpose: a failed stamp means the grace cannot be promised and dispatching anyway is the unsafe direction, whereas a failed withdrawal only delays recovery by one grace and must not mask the dispatch error underneath it. Verification type-check clean · check:audits 32/32 · 754 tests across lib/knowledge and all four knowledge API suites. Ten mutations, all red. The flagship — restoring failed to unconditionally sweepable, i.e. exactly today's staging behavior — turns four tests red. Three more separately kill each scoping guarantee on the withdrawal (own ids, pending guard, own-stamp CAS), and two kill the derivation inputs. One thing the tests cannot cover, stated rather than implied: that the withdrawal fires only on total failure. Under test isTriggerAvailable() is false, so every path goes in-process and fails — there is no way to make a dispatch succeed, so a mutation moving the clear outside the dispatched === 0 branch would not be caught. That branch is three lines and reviewable by eye. Follow-up, deliberately not here A processing_attempts column would convert the deterministic-OOM case from an unbounded seven-day re-sweep loop into a real resolution: increment inside the funnel's existing guarded write, reset on successful completion, sweep skips above N, leaving the document at failed with its error visible and the user's retry button still working. The same counter doubles as a dispatch generation — a worker carrying the value it was dispatched with can decline to bill when the row has moved past it, which is the state-based guarantee a timing grace structurally cannot give. Those two belong in one change rather than two columns a month apart, and both deserve their own review rather than riding on a hotfix.

Open Graph Description: Live on staging. Found by an independent audit of the merged connector work — an interaction between #6920 and #6921, each correct alone. The bug The sweep treats failed as terminal, documented as ...

X Description: Live on staging. Found by an independent audit of the merged connector work — an interaction between #6920 and #6921, each correct alone. The bug The sweep treats failed as terminal, documented as ...

Opengraph URL: https://github.com/simstudioai/sim/pull/6924

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:07877e82-f1d3-3119-f4ae-648bc9f000ee
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD5D4:FBC06:F7F3C8:1556CE0:6AFB657D
html-safe-nonce94f36004896834b8f142289231510898067f1360ce2bc1b1cf29f79ca95e154e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENUQ0OkZCQzA2OkY3RjNDODoxNTU2Q0UwOjZBRkI2NTdEIiwidmlzaXRvcl9pZCI6IjU3NTc0NjA3NzY1NTc5NjI2MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmace441540930e74ab4ba3065ad52debf93fdff49a9ae614590c765aaa969700e0d
hovercard-subject-tagpull_request:4328185050
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6924/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altLive on staging. Found by an independent audit of the merged connector work — an interaction between #6920 and #6921, each correct alone. The bug The sweep treats failed as terminal, documented as ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release59ef97164c52cf59bd10558ddec9c4f482763988
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/6924/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6924%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6924%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/6924/files
Reloadhttps://github.com/simstudioai/sim/pull/6924/files
Reloadhttps://github.com/simstudioai/sim/pull/6924/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests197 (197)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
fix/failed-gracehttps://github.com/simstudioai/sim/tree/fix/failed-grace
Conversation 3 https://github.com/simstudioai/sim/pull/6924
Commits 1 https://github.com/simstudioai/sim/pull/6924/commits
Checks 30 https://github.com/simstudioai/sim/pull/6924/checks
Files changed https://github.com/simstudioai/sim/pull/6924/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6924/files
fix(knowledge): give failed documents a grace while their retries are still scheduled https://github.com/simstudioai/sim/pull/6924/files#top
Show all changes 1 commit https://github.com/simstudioai/sim/pull/6924/files
8383208 fix(knowledge): give failed documents a grace while their retries are… waleedlatif1 Aug 21, 2026 https://github.com/simstudioai/sim/pull/6924/commits/83832082d5e5d711e1c3ef02f00d9f7eaafb75af
Clear filters https://github.com/simstudioai/sim/pull/6924/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6924/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6924/files
sync-engine.test.ts https://github.com/simstudioai/sim/pull/6924/files#diff-021afebf7e100833ecdc940e307263436964ce85ef3dfd40fc90307a1d115534
sync-engine.ts https://github.com/simstudioai/sim/pull/6924/files#diff-277f76464f02682e44e6de58ebd215c927f0f6a3a7165af669a0717b593790e9
retry-processing-grace.test.ts https://github.com/simstudioai/sim/pull/6924/files#diff-24e9b3a40786dff73fbb7dc3d959893039829339609677b1b55c06fd4f2ccddd
service.ts https://github.com/simstudioai/sim/pull/6924/files#diff-12adff6ec055d413ec20f1debed4ca207b994d23df6de9aa4ef79bf47f2857b2
apps/sim/lib/knowledge/connectors/sync-engine.test.tshttps://github.com/simstudioai/sim/pull/6924/files#diff-021afebf7e100833ecdc940e307263436964ce85ef3dfd40fc90307a1d115534
View file https://github.com/simstudioai/sim/blob/83832082d5e5d711e1c3ef02f00d9f7eaafb75af/apps/sim/lib/knowledge/connectors/sync-engine.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6924/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6924/files#diff-021afebf7e100833ecdc940e307263436964ce85ef3dfd40fc90307a1d115534
https://github.com/simstudioai/sim/pull/6924/files#diff-021afebf7e100833ecdc940e307263436964ce85ef3dfd40fc90307a1d115534
https://github.com/simstudioai/sim/pull/6924/files#diff-021afebf7e100833ecdc940e307263436964ce85ef3dfd40fc90307a1d115534
https://github.com/simstudioai/sim/pull/6924/files#diff-021afebf7e100833ecdc940e307263436964ce85ef3dfd40fc90307a1d115534
https://github.com/simstudioai/sim/pull/6924/files#diff-021afebf7e100833ecdc940e307263436964ce85ef3dfd40fc90307a1d115534
https://github.com/simstudioai/sim/pull/6924/files#diff-021afebf7e100833ecdc940e307263436964ce85ef3dfd40fc90307a1d115534
apps/sim/lib/knowledge/connectors/sync-engine.tshttps://github.com/simstudioai/sim/pull/6924/files#diff-277f76464f02682e44e6de58ebd215c927f0f6a3a7165af669a0717b593790e9
View file https://github.com/simstudioai/sim/blob/83832082d5e5d711e1c3ef02f00d9f7eaafb75af/apps/sim/lib/knowledge/connectors/sync-engine.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6924/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6924/files#diff-277f76464f02682e44e6de58ebd215c927f0f6a3a7165af669a0717b593790e9
https://github.com/simstudioai/sim/pull/6924/files#diff-277f76464f02682e44e6de58ebd215c927f0f6a3a7165af669a0717b593790e9
https://github.com/simstudioai/sim/pull/6924/files#diff-277f76464f02682e44e6de58ebd215c927f0f6a3a7165af669a0717b593790e9
https://github.com/simstudioai/sim/pull/6924/files#diff-277f76464f02682e44e6de58ebd215c927f0f6a3a7165af669a0717b593790e9
https://github.com/simstudioai/sim/pull/6924/files#diff-277f76464f02682e44e6de58ebd215c927f0f6a3a7165af669a0717b593790e9
https://github.com/simstudioai/sim/pull/6924/files#diff-277f76464f02682e44e6de58ebd215c927f0f6a3a7165af669a0717b593790e9
https://github.com/simstudioai/sim/pull/6924/files#diff-277f76464f02682e44e6de58ebd215c927f0f6a3a7165af669a0717b593790e9
apps/sim/lib/knowledge/documents/retry-processing-grace.test.tshttps://github.com/simstudioai/sim/pull/6924/files#diff-24e9b3a40786dff73fbb7dc3d959893039829339609677b1b55c06fd4f2ccddd
View file https://github.com/simstudioai/sim/blob/83832082d5e5d711e1c3ef02f00d9f7eaafb75af/apps/sim/lib/knowledge/documents/retry-processing-grace.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6924/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6924/files#diff-24e9b3a40786dff73fbb7dc3d959893039829339609677b1b55c06fd4f2ccddd
https://github.com/simstudioai/sim/pull/6924/files#diff-24e9b3a40786dff73fbb7dc3d959893039829339609677b1b55c06fd4f2ccddd
https://github.com/simstudioai/sim/pull/6924/files#diff-24e9b3a40786dff73fbb7dc3d959893039829339609677b1b55c06fd4f2ccddd
https://github.com/simstudioai/sim/pull/6924/files#diff-24e9b3a40786dff73fbb7dc3d959893039829339609677b1b55c06fd4f2ccddd
https://github.com/simstudioai/sim/pull/6924/files#diff-24e9b3a40786dff73fbb7dc3d959893039829339609677b1b55c06fd4f2ccddd
https://github.com/simstudioai/sim/pull/6924/files#diff-24e9b3a40786dff73fbb7dc3d959893039829339609677b1b55c06fd4f2ccddd
apps/sim/lib/knowledge/documents/service.tshttps://github.com/simstudioai/sim/pull/6924/files#diff-12adff6ec055d413ec20f1debed4ca207b994d23df6de9aa4ef79bf47f2857b2
View file https://github.com/simstudioai/sim/blob/83832082d5e5d711e1c3ef02f00d9f7eaafb75af/apps/sim/lib/knowledge/documents/service.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6924/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6924/files#diff-12adff6ec055d413ec20f1debed4ca207b994d23df6de9aa4ef79bf47f2857b2
https://github.com/simstudioai/sim/pull/6924/files#diff-12adff6ec055d413ec20f1debed4ca207b994d23df6de9aa4ef79bf47f2857b2
https://github.com/simstudioai/sim/pull/6924/files#diff-12adff6ec055d413ec20f1debed4ca207b994d23df6de9aa4ef79bf47f2857b2
https://github.com/simstudioai/sim/pull/6924/files#diff-12adff6ec055d413ec20f1debed4ca207b994d23df6de9aa4ef79bf47f2857b2
Please reload this pagehttps://github.com/simstudioai/sim/pull/6924/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.