BCP 任务在执行时挂起

发布于 2024-09-03 03:21:26 字数 1046 浏览 2 评论 0原文

我们有一个 HPC 节点,可以在其中运行一些任务。我的 .net 项目中有一个任务,该任务在 HPC 节点上启动 bcp 实用程序,并且我运行的查询输出为 9 Mb。

当 HPC 节点运行此任务时,查询的输出将转储到文件中,然后在转储大约 5mb 的数据后,它突然停止转储更多数据,并且这种情况一直在发生。 (请注意,这不是任何数据问题,因为它不会每次都在特定行上崩溃)。这可能重要也可能不重要,但我将数据转储到具有足够权限集的不同服务器中。

我直接在 hpc 节点和其他组件上运行具有相同查询的命令,它给出了正确的输出。

我运行 bcp 命令如下:

var processInfo = new ProcessStartInfo("bcp.exe", argument) { 重定向标准输出 = true, 重定向标准错误 = true, 创建无窗口 = true, UseShellExecute = false };

        var proc = new Process { StartInfo = processInfo, EnableRaisingEvents = true };
        proc.Exited += new EventHandler(bcp_log);
        proc.Start();
        proc.WaitForExit();

因此,我的代码实际上等待每个 bcp 任务运行,然后再继续,因为我多次调用它。

仅供参考,再次提醒您,只有当我的 o/p 超过一定字节数(在本例中约为 5mb)时,它才会失败。

非常感谢任何帮助。

PS:我想添加 bcp 实用程序安装在所有 HPC 节点上

We have a HPC node that runs some of our tasks in it. I have a task in my .net project that kicks the bcp utility on the HPC node and the output of the query that I have runs into 9 Mb.

When the HPC node runs this task the output of the query is dumped into a file and then after it dumps around 5mb of data it suddenly stops dumping any more data and this happens all the time. (Please note this isnt any data issue as its not crashing on a particular row every time). this may or may not be of significance but I dump the data into a different server which has adequate permissions set.

I have run the command with the same query directly on the hpc node and on other comps and it gives the right output.

I'm running the bcp command as follows:

var processInfo = new ProcessStartInfo("bcp.exe", argument)
{
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
UseShellExecute = false
};

        var proc = new Process { StartInfo = processInfo, EnableRaisingEvents = true };
        proc.Exited += new EventHandler(bcp_log);
        proc.Start();
        proc.WaitForExit();

So my code actually waits for each bcp task to run before it goes ahead as I call it multiple times.

FYI to remind you again it only fails when my o/p exceeds a certain no of bytes in this case approx 5mb.

Any help is much appreciated.

P.S: I would want to add the bcp utility is installed on all the hpc nodes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

埋情葬爱 2024-09-10 03:21:26

嘿,这里的问题是 HPC 节点无法将 bcp 命令的输出重定向到标准输出。在这种情况下,标准输出有最小值,在我们的例子中,当表中的行数超过 50000 时,它不再能够重定向到标准输出。在特定时间间隔显式刷新标准输出时,您仍然可以毫无问题地重定向到标准输出

Hey the problem here was the HPC node was not able to redirect the output of the bcp command to the standard output. The standard output has a minimum in such cases and in our case when the no of rows in our table exceeded more than 50000 it no longer was able to redirect to the standard output. on explicitly flushing the standard output at certain time intervals you can still redirect to the standard output without any problem

箜明 2024-09-10 03:21:26

如果将 RedirectStandardOutput=true 更改为 RedirectStandardOutput=false,它是否仍然挂起?

如果上述更改避免了挂起,则在尝试通过 .NET Process 类重定向 stdout 和 stderr 流时,您可能会遇到死锁情况。下面的 MSDN 文章更详细地解释了这一点,并提供了异步读取 stderr 并避免死锁情况的示例代码。

http://msdn.microsoft.com/en-我们/library/system.diagnostics.processstartinfo.redirectstandarderror.aspx

Does it still hang if you change RedirectStandardOutput=true to RedirectStandardOutput=false?

If the above changes avoids the hang, you are probably encountering a deadlock situation that can occur when trying to redirect both stdout and stderr streams via the .NET Process class. The MSDN article below explains this in more detail and provides sample code to read stderr asyncronously and avoid the deadlock condition.

http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandarderror.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文