最近有一个问题真的很挑战我,我已经浪费了将近 15 天来找出根本原因。但不幸的是,到目前为止还没有运气。
以下是详细信息,
作为我们在应用程序中向客户提供的功能的一部分,客户可以排队作业列表并让它在后台运行,并在他们排队的作业完成后让客户知道。
每个作业都应该执行 ~100K mdx 查询以完成并获得成功结果。但在幕后,我们的引擎将这 10 万个查询分成更小的块,并为每个块创建具有较少查询量的作业。在这种情况下,小型作业正在处理 1000 个查询。有了这个粗略的数字,我可以看出引擎正在创造 100 个额外的工作。然后我们的引擎开始一一执行这些小块。
并且在每个作业执行中,它都会在以下代码中运行 RunAndParseQueryResult 方法。
class Snippet
{
public static void RunAndParseQueryResult()
{
DataTable result = new DataTable();
IDbConnection conn = ConnectionFactory.CreateConnection();
conn.Open();
foreach (string mdxQuery in queryList)
{
ExecuteMdxQuery(IDbConnection connection, DataTable result, string mdxQuery)
}
conn.Close();
conn.Dispose();
}
private void ExecuteMdxQuery(IDbConnection connection, DataTable result, string mdxQuery)
{
var conn = connection as AdomdConnection;
Trace.TraceInformation("Log 1");
if (conn != null)
{
Trace.TraceInformation("Log 2");
using (AdomdCommand command = new AdomdCommand(mdxFile.Mdx, conn) { CommandTimeout = 5000 })
{
Trace.TraceInformation("Log 3");
using (AdomdDataAdapter adapter = new AdomdDataAdapter(command))
{
Trace.TraceInformation("Log 4");
try
{
DataTable dt = new DataTable();
Trace.TraceInformation("Log 5");
dt.BeginLoadData();
Trace.TraceInformation("Log 6");
adapter.Fill(dt);
Trace.TraceInformation("Log 7");
dt.EndLoadData();
Trace.TraceInformation("Log 8");
if (dt.Rows.Any())
{
Trace.TraceInformation("Log 9");
ParseQueryResult(result, mdxFile, dt);
Trace.TraceInformation("Log 10");
}
}
catch (Exception exception)
{
Trace.TraceInformation("Log 11");
throw;
}
}
}
}
else
{
throw new Exception("Given cube connection can not be casted to AdoMdConnection");
}
}
}
如您所见,RunAndParseQueryResult 方法打开连接并将其与 mdxQuery 循环变量一起传递给 ExecuteMdxQuery 方法。
在 ExecuteMdxQuery 方法中,几乎在每一行之后,我都使用 Trace.TraceInformation 方法放置了一个日志。
发生的事情是在某些迭代 ExecuteMdxQuery 方法停止在
adapter.Fill(dt);
方法。我通过查看日志来解决这个问题。因为如果它成功执行,我会看到像“Log 7”这样的日志,或者如果它执行失败,我应该能够看到“Log 11”。但是这些行似乎都没有运行。
当我手动运行查询时,它工作正常。该查询绝对不是长时间运行的查询,即使它是,我们已经指定了超时 5000 秒
AdomdCommand command = new AdomdCommand(mdxFile.Mdx, conn) { CommandTimeout = 5000 }
代码,它假设正常抛出 TimeOutException。但事实并非如此。
任何意见为什么会这样?
先感谢您。