Metadata snapshot cache keys aren't scoped by database: servers on different databases sharing a Redis DB overwrite each other's metadata
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- redis, typescript
- 領域
- backend
調査の方向性
LocalStoragePrefix を packages/MJCore/src/generic/providerBase.ts で読み、それが静的キーフィールドにどのように連結されるかを追い、次に GraphQLDataProvider のオーバーライドをコピーすべきパターンとして確認してください。SQLServerDataProvider と GenericDatabaseProvider が InstanceConnectionString を構築する箇所を見つけ、そこで LocalStoragePrefix を正規化され、区切り文字を末尾に付けた形式でオーバーライドしてください。完了とは、異なるデータベースを指す 2 つのプロバイダーが 1 つの Redis 論理 DB を共有していても、異なるメタデータスナップショットキーを生成することであり、ロード後にキーを検査することで検証できます。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TSQL
- スター
- 32
- フォーク
- 7
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 504
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MemberJunction/MJ のほかの issue
-
DBAutoDoc: export --state-file writes SQL Server SQL for a PostgreSQL database, ignoring --providerオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
MemberJunction/MJ#7094 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
MemberJunction/MJ#6971 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
MemberJunction/MJ#6947 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
MemberJunction/MJ#6746 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
MemberJunction/MJ#6721 ·
メンテナーはふだん 1 日以内に返信
MemberJunction/MJ の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
OHDSI/Data2Evidence#3815 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
roc-lang/basic-webserver#277 ·
メンテナーはふだん 1 日以内に返信
-
e2e-failure ready-to-code
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
redhat-developer/rhdh-plugin-export-overlays#4995 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
fidelity
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Azure SAS signing uses local time instead of UTC, shifting validity window on non-UTC hosts対応中かも @huanghaoyuanhhy が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
zilliztech/milvus-backup#1418 ·
メンテナーはふだん 1 日以内に返信