JobServer constructor shouldn't run a SQL query
まだ誰も着手していません。
評価
調査の方向性
issue に示されている JobServer コンストラクターから始め、parentsrv.Databases["msdb"] が StringComparer をどのように取得するかを調べます。これを SqlSmoObject に既に存在する StringComparer の遅延読み込みと比較し、提供されている ClearAndInitialize テストシナリオを使って、JobServer を構築しても Databases が設定されず、msdb が存在しない場合にも失敗しないことを検証します。
索引モデルが issue の本文から書いたものです。
説明
the JobServer class requires initializing its parent's Databases collection to construct itself:
internal JobServer(Server parentsrv, ObjectKeyBase key, SqlSmoState state) :
base(key, state)
{
// even though we called with the parent collection of the column, we will
// place the JobServer under the right collection
singletonParent = parentsrv as Server;
// WATCH OUT! we are setting the m_server value here, because JobServer does
// not live in a collection, but directly under the Database
SetServerObject( parentsrv.GetServerObject());
m_comparer = parentsrv.Databases["msdb"].StringComparer;
jobCategories = null;
alertCategories = null;
operatorCategories = null;
alertSystem = null;
alerts = null;
operators = null;
targetServers = null;
targetServerGroups = null;
jobs = null;
sharedSchedules = null;
}
- It shouldn't be making a SQL query of any kind in the constructor anyway
- Populating the databases collection is hugely expensive
- SqlSmoObject has a way to delay load StringComparer already that doesn't populate the collection, this object may just need a little refactoring of that method to support specifying msdb as the database to use for the query.
I found this by accident while trying to write a test for something else.
This code blows up because Databases["msdb"] doesn't exist:
var smoFilter = "[contains(@Name, 'SmoBaseline')]";
db.Parent.Databases.ClearAndInitialize($"[@Name='{Urn.EscapeString(db.Name)}']", Enumerable.Empty<string>());
db.Parent.Logins.ClearAndInitialize(smoFilter, Enumerable.Empty<string>());
db.Parent.LinkedServers.ClearAndInitialize(smoFilter, Enumerable.Empty<string>());
if (db.Parent.IsSupportedObject<JobServer>())
{
db.Parent.JobServer.Jobs.ClearAndInitialize(smoFilter, Enumerable.Empty<string>());
}
- 主要言語
- C#
- スター
- 143
- フォーク
- 28
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/sqlmanagementobjects のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 74/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
microsoft/sqlmanagementobjects の issue をすべて見る
似ている issue
-
area-ai untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/extensions#7783 ·
-
untriaged
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
dotnet/dotnet-api-docs#13095 ·
-
area-deployment area-integrations triage:bot-seen
難易度 2/5 半日 初心者へのやさしさ 86/100
-
type/automation type/tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
newrelic/newrelic-dotnet-agent#3850 · コメント 1 件 ·