A v2 versioning write costs queries proportional to the flag's segment overrides
I maintainer di solito rispondono entro 1 giorno
@Ishita-Singh-12 ci sta già lavorando.
Dal 3/10/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- python
- Ambito
- backend, performance
Direzione di ricerca
Inizia con FeatureState.clone e FeatureSegment.clone in api/features/models.py, quindi segui EnvironmentFeatureVersion.objects.create(...) e version.publish(...) utilizzando le misurazioni di CaptureQueriesContext riportate. Esamina il percorso di pubblicazione e i relativi gestori dei segnali alla ricerca di lookup delle relazioni per ogni stato e aggiungi un test del conteggio delle query a livello di servizio che copra l’ambito di ottimizzazione selezionato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Every write to a flag in a v2-versioned environment opens a new EnvironmentFeatureVersion and publishes it. Both halves of that cost grow with the number of feature states the flag has, so a flag with many segment overrides pays a query count proportional to its overrides.
Measured on main with CaptureQueriesContext around EnvironmentFeatureVersion.objects.create(...) and version.publish(...), for a flag with 1 and with 3 segment overrides (2 and 4 feature states):
| Step | 1 override | 3 overrides | Per extra state |
|---|---|---|---|
EnvironmentFeatureVersion.objects.create |
26 | 54 | ~8 |
version.publish |
45 | 61 | ~5 |
Extrapolated, a flag with 50 segment overrides costs roughly 400 queries to open a version and 250 to publish it. Every v2 write path pays this: the versioning serializers, change request commits, and the experimental update-flag endpoints alike.
Creating a version copies row by row
FeatureState.clone (api/features/models.py:661) is a deepcopy plus save() per state, and FeatureSegment.clone (api/features/models.py:328) does the same. Per cloned state the create issues, roughly:
SELECT features_featureSELECT features_featurestatevalueINSERT features_featurestateandINSERT features_historicalfeaturestateINSERT features_featurestatevalueandINSERT features_historicalfeaturestatevalue- a
SAVEPOINT/RELEASEpair
Some copying is inherent to immutable versions, but the row-at-a-time shape is not: bulk_create for the states and their values, with the history rows batched alongside, would collapse most of it.
Publishing re-fetches relations per state
This half looks like a plain N+1 rather than inherent work. Between 1 and 3 overrides, publish goes from 45 to 61 queries, and the growth is all in per-state relation lookups:
| Query | 1 override | 3 overrides |
|---|---|---|
SELECT multivariate_multivariatefeaturestatevalue |
6 | 10 |
SELECT features_feature |
4 | 8 |
SELECT features_featurestatevalue |
4 | 8 |
SELECT features_featuresegment |
3 | 7 |
Whatever the publish path and its signal handlers iterate should be able to hydrate these with select_related / prefetch_related in one pass.
Suggested scope
- Flatten the publish-side N+1 first — it is the cheaper fix and is not intrinsic to versioning.
- Then consider bulk-creating the cloned states, values and multivariate values when a version is created.
Worth pinning either fix with a query-count test at the service level.
- Lingua principale
- Python
- Stelle
- 9.9k
- Fork
- 658
- Merge medio
- 1g 15h
- PR unite (30g)
- 168
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Flagsmith/flagsmith
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Flagsmith/flagsmith#9119 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Fix Button Alignment in SDK Installation SectionForse già presa @manueldezman l’ha presa 3 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Flagsmith/flagsmith#9056 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Cloud Python warehouse snippet omits the import needed by its short-lived-job guidanceForse già presa @jcd1991 l’ha presa 4 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
Flagsmith/flagsmith#9045 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Expose whether an organisation is blocked for API usageForse già presa @PiUnknown l’ha presa 38 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Flagsmith/flagsmith#8773 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
influx_query_manager doesn't catch ApiException, so Influx error responses 500Forse già presa @SAY-5 l’ha presa 13 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
Flagsmith/flagsmith#8510 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Flagsmith/flagsmith
Issue simili
-
ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
ARTPARK-SAHAI-ORG/calibrate-frontend#919 ·
I maintainer di solito rispondono entro 1 giorno
-
CI: MSYS2 jobs fail — mingw python3 package renamed upstream to pythonForse già presa @ronaldtse l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
pydantic/pytest-examples#102 · 1 commento ·