系统调用超时?

发布于 2024-09-04 14:49:02 字数 124 浏览 4 评论 0原文

我正在使用 unix system() 调用 Gunzip 和 gzip 文件。对于非常大的文件,有时(即在集群计算节点上)这些文件会被中止,而其他时候(即在登录节点上)它们会通过。系统调用可能花费的时间是否有一些软限制?还能是什么?

I'm using unix system() calls to gunzip and gzip files. With very large files sometimes (i.e. on the cluster compute node) these get aborted, while other times (i.e. on the login nodes) they go through. Is there some soft limit on the time a system call may take? What else could it be?

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

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

发布评论

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

评论(5

╰沐子 2024-09-11 14:49:02

调用线程应该无限期地阻塞,直到您使用 system() 启动的任务完成。如果您观察到调用返回并且文件操作未完成,则表明生成的操作由于某种原因失败。

返回值表示什么?

The calling thread should block indefinitely until the task you initiated with system() completes. If what you are observing is that the call returns and the file operation as not completed it is an indication that the spawned operation failed for some reason.

What does the return value indicate?

美煞众生 2024-09-11 14:49:02

几乎可以肯定,这不是使用 system() 的问题,而是您正在执行的操作的问题。始终检查返回值,但更重要的是,您需要查看正在调用的命令的输出。对于非交互式使用,通常最好将 stdout 和 stderr 写入日志文件。一种方法是编写一个包装脚本来检查底层命令、记录命令行、重定向 stdout 和 stderr(如果您想小心的话,还可以关闭 stdin),然后执行命令行。通过 system() 而不是直接运行操作系统命令来运行它。

我敢打赌,故障机器的磁盘空间有限,或者缺少目标文件或实际的 gzip/gunzip 命令。

Almost certainly not a problem with use of system(), but with the operation you're performing. Always check the return value, but even more so, you'll want to see the output of the command you're calling. For non-interactive use, it's often best to write stdout and stderr to log files. One way to do this is to write a wrapper script that checks for the underlying command, logs the commandline, redirects stdout and stderr (and closes stdin if you want to be careful), then execs the commandline. Run this via system() rather than the OS command directly.

My bet is that the failing machines have limited disk space, or are missing either the target file or the actual gzip/gunzip commands.

千鲤 2024-09-11 14:49:02

我正在使用 unix system() 调用
gunzip 和 gzip 文件。

可能很愚蠢的问题:为什么不直接从应用程序中使用 zlib?

system() 不是系统调用。它是 fork()/exec()/wait() 的包装。检查 system() 手册页。如果它没有解除阻止,则可能是您的应用程序以某种方式干扰了 wait() - 例如,您是否有 SIGCHLD 处理程序?

I'm using unix system() calls to
gunzip and gzip files.

Probably silly question: why not use zlib directly from your application?

And system() isn't a system call. It is a wrapper for fork()/exec()/wait(). Check the system() man page. If it doesn't unblock, it might be that your application interferes somehow with wait() - e.g. do you have a SIGCHLD handler?

鲜血染红嫁衣 2024-09-11 14:49:02

如果是 Linux 系统,我建议使用 strace 来查看发生了什么以及哪个系统调用被阻止。

您甚至可以将 strace 附加到已经运行的进程:
# strace -p $PID

If it's a Linux system I would recommend using strace to see what's going on and which syscall blocks.

You can even attach strace to already running processes:
# strace -p $PID

来日方长 2024-09-11 14:49:02

听起来我遇到了同样的间歇性问题,表明某种超时。我的脚本每天都会运行。我开始相信 GZIP 已经超时了。

  1. gzip -vd 文件名.txt.gz 2>> tmp/errorcatch.txt 1>> logfile.log
  2. stderr: filename.txt.gz 错误
  3. 移至下一个命令“cp filename* new/directory/”,导致新目录
  4. stdout 中的文件名的压缩版本来自早期 gzip,显示成功解压缩相同文件:
    filename.txt.gz: 95.7% -- 替换为 filename.txt
  5. 来自 gzip 的成功文件不在源目录或新目录中。
  6. 出现警报后,手动运行“gzip -vd filename.txt.gz”永远不会失败。

详细信息:

  • 脚本中只有一次调用来解压缩该文件
  • 对解压缩的调用位于函数内部(用于更多重新启动日志记录和警报)
  • 无法在生产中跟踪
  • 无法本地复制
  • 在上个月发生的情况中,发现文件大小之间没有一致性,只有

我只需通过重试逻辑和一般脚本改进来解决它,但我希望下一个谷歌人知道他们并不疯狂。这种事也发生在其他人身上!

Sounds like I'm running into the same intermittent issue indicating a timeout of some kind. My script runs every day. I'm starting to believe GZIP has a timeout.

  1. gzip -vd filename.txt.gz 2>> tmp/errorcatch.txt 1>> logfile.log
  2. stderr: Error for filename.txt.gz
  3. Moves to next command 'cp filename* new/directory/', resulting in zipped version of filename in new directory
  4. stdout from earlier gzip showing successful unzip of SAME file:
    filename.txt.gz: 95.7% -- replaced with filename.txt
  5. Successful out file from gzip is not there in source or new directory.
  6. Following alerts, manual run of 'gzip -vd filename.txt.gz' never fails.

Details:

  • Only one call in script to unzip that file
  • Call for unzip is inside a function (for more rebust logging and alerting)
  • Unable to strace in production
  • Unable to replicate locally
  • In occurences over last month, found no consistency among file size, only

I'll simply be working around it with a retry logic and general scripting improvements, but I want the next google-er to know they're not crazy. This is happening to other people!

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