Hudson SCM 轮询线程在轮询时挂起

发布于 2024-11-03 04:00:21 字数 159 浏览 1 评论 0原文

我们使用 Hudson 作为我们的持续构建环境。由于某种原因,SCM 轮询的线程有时会在一段时间后挂起。我对这些设置进行了很多尝试,但似乎没有什么真正起作用。如何解决这个问题,是否有一些脚本可以检测到这种情况以便能够重新启动 hudson?顺便提一句。重新启动 hudson 是目前解决此问题的唯一方法。

We use Hudson for our continuose build environment. For some reason, the thread for SCM Polling hungs somethimes after a while. I've experiemented a lot with the settings, but nothing seems to really work. How to fix this and are there some scripts out there which can detect such a case to be able to restart hudson? Btw. restarting hudson is the only way to solve this issue for us at the moment.

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

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

发布评论

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

评论(2

戈亓 2024-11-10 04:00:21

这类似于 bug 5413,自 2010 年底以来应该通过 HUDSON 5977(Hudson 1.380+,或现在的 Jenkins)。

您在这些线程中 某种方法来杀死卡在轮询步骤上的任何线程

非常原始(我懒得开发更好的东西,因为这不是很重要的问题)Groovy 脚本如下。
它也可能会终止没有卡住的 SCM 轮询,但我们每天只自动运行此脚本一次,因此它不会给我们带来任何麻烦。
您可以通过保存 SCM 轮询线程的 id 和名称来改进它,一段时间后再次检查并仅杀死 id 位于先前检查列表中的线程。

Thread.getAllStackTraces().keySet().each(){ item ->
  if( item.getName().contains("SCM polling") && 
      item.getName().contains("waiting for hudson.remoting")){ 
     println "Interrupting thread " + item.getId() item.interrupt() 
  }
}

That is similar to bug 5413, which should be solved since late 2010 with HUDSON 5977 (Hudson 1.380+, or now Jenkins).

You had in those thread some way to kill any thread stuck on the polling step:

very primitive (I'm too lazy to develop something better as this is not very important issue) Groovy script is bellow.
It could happened that it will kill also SCM polling which are not stuck, but we run this script automatically only once a day so it doesn't cause any troubles for us.
You can improve it e.g. by saving ids and names of SCM polling threads, check once again after some time and kill only threads which ids are on the list from previous check.

Thread.getAllStackTraces().keySet().each(){ item ->
  if( item.getName().contains("SCM polling") && 
      item.getName().contains("waiting for hudson.remoting")){ 
     println "Interrupting thread " + item.getId() item.interrupt() 
  }
}
草莓味的萝莉 2024-11-10 04:00:21

另一个答案对我不起作用,但以下脚本 发现了此问题问题做了:

Jenkins.instance.getTrigger("SCMTrigger").getRunners().each()
{
  item ->
  println(item.getTarget().name)
  println(item.getDuration())
  println(item.getStartTime())
  long millis = Calendar.instance.time.time - item.getStartTime()

  if(millis > (1000 * 60 * 3)) // 1000 millis in a second * 60 seconds in a minute * 3 minutes
  {
    Thread.getAllStackTraces().keySet().each()
    { 
      tItem ->
      if (tItem.getName().contains("SCM polling") && tItem.getName().contains(item.getTarget().name))
      { 
        println "Interrupting thread " + tItem.getName(); 
        tItem.interrupt()
      }
    }
  }
}

The other answer didn't work for me, but the following script found the the issue for this problem did:

Jenkins.instance.getTrigger("SCMTrigger").getRunners().each()
{
  item ->
  println(item.getTarget().name)
  println(item.getDuration())
  println(item.getStartTime())
  long millis = Calendar.instance.time.time - item.getStartTime()

  if(millis > (1000 * 60 * 3)) // 1000 millis in a second * 60 seconds in a minute * 3 minutes
  {
    Thread.getAllStackTraces().keySet().each()
    { 
      tItem ->
      if (tItem.getName().contains("SCM polling") && tItem.getName().contains(item.getTarget().name))
      { 
        println "Interrupting thread " + tItem.getName(); 
        tItem.interrupt()
      }
    }
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文