JobServer constructor shouldn't run a SQL query
还没有人认领这个 Issue。
评估
调研方向
从 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 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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
-
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 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
LuckyPennySoftware/AutoMapper#4660 ·