Metadata snapshot cache keys aren't scoped by database: servers on different databases sharing a Redis DB overwrite each other's metadata
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- redis, typescript
- Ambito
- backend
Direzione di ricerca
Leggi LocalStoragePrefix in packages/MJCore/src/generic/providerBase.ts e segui come viene concatenato nei campi chiave statici, poi guarda l'override di GraphQLDataProvider come modello da copiare. Trova dove SQLServerDataProvider e GenericDatabaseProvider costruiscono il loro InstanceConnectionString e sovrascrivi LocalStoragePrefix lì con una forma normalizzata, con separatore come suffisso. Fatto significa che due provider puntati a database diversi che condividono un unico DB logico Redis producono chiavi di snapshot dei metadati distinte, verificabile ispezionando le chiavi dopo un caricamento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
The metadata snapshot that ProviderBase saves to the shared cache is keyed without the database it came from. Two server processes connected to different databases that share one Redis logical database overwrite each other's snapshot. Whichever process loads after the other's write gets the other database's entity metadata.
Other shared-cache keys are scoped by connection; these are not.
Where
packages/MJCore/src/generic/providerBase.ts (on next):
private static localStorageRootKey = '___MJCore_Metadata'
private static localStorageTimestampsKey = this.localStorageRootKey + '_Timestamps'
private static localStorageAllMetadataKey = this.localStorageRootKey + '_AllMetadata'
private static localStorageFormatKey = this.localStorageRootKey + '_Format'
private static localStorageDatasetMembershipKey = this.localStorageRootKey + '_DatasetMembership'
private static localStorageDatasetItemsKey = this.localStorageRootKey + '_DatasetItems'
These are prefixed with LocalStoragePrefix, which defaults to "":
protected get LocalStoragePrefix(): string {
return "";
}
GraphQLDataProvider overrides it with its endpoint URL, for exactly this reason (its doc comment says so). The database providers (SQLServerDataProvider, and the PostgreSQL provider through GenericDatabaseProvider) don't. So on a server the keys come out as:
mj:default:___MJCore_Metadata_AllMetadata
mj:default:___MJCore_Metadata_Timestamps
mj:default:___MJCore_Metadata_Format
mj:default:___MJCore_Metadata_DatasetMembership
By contrast, dataset and RunView cache keys carry the connection, for example
mj:DatasetCache:___MJCore_Metadatamssql://localhost:1433/<db>__DATASET__MJ_Metadata and mj:RunViewCache:…|mssql://localhost:1433/<db>. BaseEngine also keys its own state by InstanceConnectionString.
Observed (6.2.2, local)
- Two server processes, each with its own SQL Server database (one with 546 entities, the other with 505), used the same Redis instance and logical DB 0, both with key prefix
mj. - Both started at about the same moment.
- The 546-entity server came up with the other database's 505-entity metadata. It then failed on its own entities with
Entity <name> not found in metadata. - With one process started well before the other, the problem did not show. That fits a race on the shared snapshot key.
- Giving each process its own Redis logical DB (
redis://host:port/1) made it go away.
Expected
A provider's metadata snapshot is keyed by the connection it describes, as the dataset and RunView caches already are. Two servers on different databases can then share a Redis instance without reading each other's metadata.
Suggested fix
Override LocalStoragePrefix in the database providers to return a normalized InstanceConnectionString (with a separator), mirroring GraphQLDataProvider's URL-based prefix.
Notes:
- Changing the key orphans existing snapshots under the old key once, after an upgrade. They're rebuilt on the next load, and they're a cache, so that should be harmless.
- The browser path is unchanged: it already gets a URL prefix.
Workaround
Don't let MJ server processes that use different databases share a Redis logical DB. Give each its own DB index or instance.
- Lingua principale
- TSQL
- Stelle
- 32
- Fork
- 7
- Merge medio
- 1g 16h
- PR unite (30g)
- 504
Preparare l'ambiente
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 MemberJunction/MJ
-
DBAutoDoc: export --state-file writes SQL Server SQL for a PostgreSQL database, ignoring --providerAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
MemberJunction/MJ#7094 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
MemberJunction/MJ#6971 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
MemberJunction/MJ#6947 ·
I maintainer di solito rispondono entro 1 giorno
-
Convention: saved-query discoverability follows Status — Approved is canon, Pending is a draftAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
MemberJunction/MJ#6746 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MemberJunction/MJ#6721 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di MemberJunction/MJ
Issue simili
-
HXsetdir strdup leakAperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
-
funding: failure logs print `<nil>` error and zero channel IDForse già presa @litbot-9000 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
lightningnetwork/lnd#11676 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
Fei2411/DeepSeek-Bot#2891 ·
-
factory:subtask
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno