Skip to content

Commit 8a7bc96

Browse files
committed
fix: review
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent e189609 commit 8a7bc96

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

backend/.env.dist.local

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,4 @@ POM_FETCHER_NON_CRITICAL_BATCH_SIZE=500
207207
POM_FETCHER_NON_CRITICAL_CONCURRENCY=20
208208
POM_FETCHER_REFRESH_DAYS=1
209209
POM_FETCHER_GROUP_DELAY_MS=100
210-
POM_FETCHER_FORCE_FULL_EXTRACTION=true
211210
POM_FETCHER_MAVEN_BASE_URL=https://maven-central.storage-download.googleapis.com/maven2

services/apps/packages_worker/src/maven/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,25 +207,25 @@ Eclipse/OSGi feature artifacts (e.g. `org.wso2.carbon.identity.xacml.server.feat
207207

208208
### Maven Central 403 rate limiting
209209

210-
Maven Central (`repo1.maven.org`) restituisce 403 come meccanismo di throttle oltre al canonico 429. Il comportamento è gestito a due livelli:
210+
Maven Central (`repo1.maven.org`) returns 403 as a throttling mechanism in addition to the canonical 429. The behaviour is handled at two levels:
211211

212-
1. **Retry con backoff esponenziale** — 403 e 429 vengono ritentati fino a 3 volte (2s base, ×2 per tentativo). Gestito in `getWithRetry` (extract.ts) e `resolveVersionsList` (metadata.ts).
212+
1. **Exponential backoff retry** — 403 and 429 are retried up to 3 times (2s base, ×2 per attempt). Handled in `getWithRetry` (extract.ts) and `resolveVersionsList` (metadata.ts).
213213

214-
2. **Retry al prossimo pass**se tutti i retry esauriscono, il batch conta il pacchetto come errore (nessun record sentinel viene scritto su `packages`) e lo riprenderà al tick/pass successivo, quando l'IP è di nuovo freddo.
214+
2. **Retry on the next pass**if all retries are exhausted, the batch counts the package as an error (no sentinel record is written to `packages`) and picks it up again on the next tick/pass, when the IP has cooled down.
215215

216-
**Causa root dei 403 persistenti:** `packages_universe` è ordinato per `rank_in_ecosystem`, quindi pacchetti dello stesso namespace (es. `com.google.apis`, `org.wso2`, `software.amazon.awssdk`) si raggruppano nel batch e colpiscono lo stesso CDN node di Maven Central in rapida successione. Il rate limit scatta sistematicamente dopo ~150–200 pacchetti processati.
216+
**Root cause of persistent 403s:** `packages_universe` is ordered by `rank_in_ecosystem`, so packages from the same namespace (e.g. `com.google.apis`, `org.wso2`, `software.amazon.awssdk`) cluster together in the batch and hit the same Maven Central CDN node in rapid succession. The rate limit consistently kicks in after ~150–200 packages processed.
217217

218-
**Mitigazione applicata, in ordine di efficacia:**
218+
**Mitigations applied, in order of effectiveness:**
219219

220-
1. **Cache in-process dei parent POM** (vedi [Parent POM cache](#parent-pom-cache)) — sfrutta il clustering per namespace per collassare i fetch dei parent condivisi e il doppio fetch del leaf POM, riducendo il **volume totale** di richieste. È la leva principale: il throttle è volume-based per IP, quindi meno richieste = meno 403.
221-
2. Un delay configurabile tra i gruppi concorrenti (`POM_FETCHER_GROUP_DELAY_MS`) + `POM_FETCHER_CONCURRENCY` basso (≤5) → abbassano il rate istantaneo.
222-
3. Backoff di retry con jitter (`±500ms`, vedi `extract.ts` / `metadata.ts`) → evita retry sincronizzati.
220+
1. **In-process parent POM cache** (see [Parent POM cache](#parent-pom-cache)) — leverages namespace clustering to collapse fetches of shared parents and the double fetch of the leaf POM, reducing the **total volume** of requests. This is the main lever: throttling is volume-based per IP, so fewer requests = fewer 403s.
221+
2. A configurable delay between concurrent groups (`POM_FETCHER_GROUP_DELAY_MS`) + low `POM_FETCHER_CONCURRENCY` (≤5) → lower the instantaneous rate.
222+
3. Retry backoff with jitter (`±500ms`, see `extract.ts` / `metadata.ts`) → avoids synchronized retries.
223223

224-
> Nota: **lo shuffle dei batch non aiuta**riordina gli stessi N request nella stessa finestra temporale (stesso volume → stesso throttle) e in più romperebbe la località che rende efficace la cache dei parent.
224+
> Note: **shuffling the batch does not help**it reorders the same N requests within the same time window (same volume → same throttle) and would additionally break the locality that makes the parent cache effective.
225225
226-
Namespace noti per triggerare il rate limit a causa dell'alta densità di artefatti: `com.google.apis`, `software.amazon.awssdk`, `org.wso2.*`.
226+
Namespaces known to trigger the rate limit due to their high artifact density: `com.google.apis`, `software.amazon.awssdk`, `org.wso2.*`.
227227

228-
**IP caldo durante i test locali:** run ripetute sulla stessa macchina accumulano request history sull'IP. Maven Central usa finestre di throttle lunghe (1–4 ore), quindi anche a concurrency=3 + delay=400ms l'IP può rimanere in stato di throttle per tutta la sessione di test. In produzione questo non accade perché le run sono distanziate di 24 ore e l'IP è sempre freddo tra un pass e l'altro. Per verificare se l'IP è throttlato: `curl -I https://repo1.maven.org/maven2/org/wso2/carbon/identity/framework/application-mgt/maven-metadata.xml`risposta 403 immediata conferma il throttle.
228+
**Hot IP during local testing:** repeated runs on the same machine accumulate request history on the IP. Maven Central uses long throttle windows (1–4 hours), so even at concurrency=3 + delay=400ms the IP can stay throttled for the entire test session. This does not happen in production because runs are spaced 24 hours apart and the IP is always cold between passes. To check whether the IP is throttled: `curl -I https://repo1.maven.org/maven2/org/wso2/carbon/identity/framework/application-mgt/maven-metadata.xml`an immediate 403 response confirms the throttle.
229229

230230
### Partial Maven Central Deploys
231231

services/apps/packages_worker/src/maven/runMavenEnrichmentLoop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import crypto from 'crypto'
22

33
import {
44
MavenPackageToSync,
5+
QueryExecutor,
56
listMavenPackagesToSync,
67
logAuditFieldChange,
78
replacePackageMaintainers,
@@ -12,7 +13,6 @@ import {
1213
upsertRepo,
1314
upsertVersionsBatch,
1415
} from '@crowd/data-access-layer'
15-
import { QueryExecutor } from '@crowd/data-access-layer/src/queryExecutor'
1616
import { getServiceChildLogger } from '@crowd/logging'
1717

1818
import { getMavenConfig } from '../config'

0 commit comments

Comments
 (0)