Intermittently met 404 when fetch /queue/item/<number>/api/json

451 views
Skip to first unread message

zhu kane

unread,
Sep 11, 2015, 2:12:45 AM9/11/15
to jenkins...@googlegroups.com
I am using Jenkins LTS 1.609.2. My app heavily depends on Jenkins remote APIs to run new job then fetch the job result later.

I noticed the Jenkins server throws 404 not found error when fetching the detail job information via queue item API.

The Jenkins server was not restarted and always runs well.

From the log of my app, I could see the 404 responses few times, it does not always happens. However it occurred again in few queue number.

I know there is a known bug JENKINS-27256 that had been fixed in 1.603. Looks like they are different issues. Does Jenkins only store queue item records in memory? I observed the queue number reseted after restarting Jenkins server. And is Jenkins using weak or soft reference to keep the queue item records? So they might lost if GC happens. 

Failed to fetch job status from       queue url 'http://127.0.0.1:8888/queue/item/378/', received code '404' and message '<html>

63736 <head>

63737 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>

63738 <title>Error 404 Not Found</title>

63739 </head>

63740 <body><h2>HTTP ERROR 404</h2>

63741 <p>Problem accessing /queue/item/378/api/json. Reason:

63742 <pre>    Not Found</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>

...

<body><h2>HTTP ERROR 404</h2>

63830 <p>Problem accessing /queue/item/382/api/json. Reason:

...

64224 <body><h2>HTTP ERROR 404</h2>

64225 <p>Problem accessing /queue/item/389/api/json. Reason:


Kane

zhu kane

unread,
Sep 12, 2015, 5:41:56 AM9/12/15
to jenkins...@googlegroups.com
After browsing the source code, I found below code changed by kohsuke in Queue.java[1],

+// private final FifoMap<Integer,LeftItem> leftItems = new FifoMap<Integer,LeftItem>(256);
+ private final Cache<Integer,LeftItem> leftItems = CacheBuilder.newBuilder().expireAfterWrite(5*60, TimeUnit.SECONDS).build();


A fixed size map was replaced by a cache which drops the items that lives more than 3 minutes.

Does it mean the third party who are using remote APIs to track the job information having to fetch the corresponding job information via queue item in 3 minutes?

What will happen if the queue item is blocked than 3 minutes due to no available executor or quiet time exceeding 3 minutes? They will be removed as well?

Thanks.



Kane

Daniel Beck

unread,
Sep 12, 2015, 9:29:34 PM9/12/15
to jenkins...@googlegroups.com

On 12.09.2015, at 11:41, zhu kane <kan...@gmail.com> wrote:

> Does it mean the third party who are using remote APIs to track the job information having to fetch the corresponding job information via queue item in 3 minutes?

It's five minutes, otherwise you're right.

> What will happen if the queue item is blocked than 3 minutes due to no available executor or quiet time exceeding 3 minutes? They will be removed as well?

This caches only "left items", i.e. those that left the queue (canceled or building), starting the moment they leave the queue.

zhu kane

unread,
Sep 12, 2015, 10:37:18 PM9/12/15
to jenkins...@googlegroups.com
Daniel,

Thanks for your explanation.

Looks like it is not easy to track the final build number if it's scheduled via remote api.

The caller only receives the queue item after scheduling a new build. And the queue item which is corresponding to the new build will be removed in 5 minutes after the scheduled build is started or canceled. However it's impossible for caller to point out the certain time when the queue item lefts queue. The scheduled new build might be ran immediately, or wait for minutes, hours or even longer. Looks like the caller has to continuously poll the queue item url every N(<300) seconds.

Is it correct? or do you know another more efficient and reliable way to track the final build state which is scheduled via remote api?


Kane


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/FC8C2B4A-90F8-4624-8F83-B88E762D023B%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages