Issues
Closed task thread IDs are reused after Lucee restart (and should not be)
Description
Environment
OS: Linux (5.4.59) 64bit
Java Version: 11.0.11 (AdoptOpenJDK) 64bit
Tomcat Version: Apache Tomcat/9.0.11
Lucee Version: 5.3.6.61 (and up to the current version)
Attachments
Details
Assignee
Michael OffnerMichael OffnerReporter
Toro MaduroToro MaduroPriority
NewLabels
Fix versions
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Sprint
None
Details
Details
Assignee
Reporter
Priority
Labels
Fix versions
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Sprint
Activity
Pothys - MitrahSoft7 December 2021 at 08:26Edited
I've checked this ticket with the lucee build 6.0.0.147-SNAPSHOT and now the issue was solved. After Restart the Lucee checks both open/close tasks id before creating a new task id.
https://github.com/lucee/Lucee/commit/3970b512e763b78b49e99744074ecfa4c5660696
Michael Offner6 December 2021 at 13:50
Pothys - MitrahSoft6 September 2021 at 15:52
I've added a fix to this ticket
Pull Request: https://github.com/lucee/Lucee/pull/1424
Toro Maduro4 September 2021 at 19:51
Yup, Pothys, you’re seeing exactly what I saw. The problem’s root cause is almost certainly a query or similar lookup in the code at the point where a new task ID is generated that looks at the ID numbers of all OPEN tasks, and makes sure to pick an ID that isn’t one of them.
The fix should be simple - just change the OPEN to ALL. Problem solved!
Pothys - MitrahSoft3 September 2021 at 08:17Edited
After restart/startup on lucee, If already there are tasks like an open task with IDs (1,2 & 5) and closed task with IDs(3, 4) means while creating a new task lucee reuses the closed task ids(3, 4). And also viewing the edit page shows both open and closed task details together (see attached image).
TL/DR:
_
Lucee re-uses closed task ID numbers after a restart, and it shouldn’t. Delete all tasks (on the admin’s “Services - Tasks” page). Restart Lucee. Make a task, cause it to become closed. Restart Lucee. Make another task. Both have ID = 1. Click detail for either, you see detail for both. NOT GOOD, needs fix._
FULL TEXT:
It seems there’s a bug with task threads. Here’s how to reproduce it:
1. Make sure there are no task threads (delete all if needed).
2. Shutdown Lucee.
3. Start Lucee.
These three steps appear to ensure that when we create a task thread, it’ll have ID = 1.
4. Create a task thread that always fails (contains just a CFTHROW for example). It will be given ID = 1.
5. Repeatedly execute it (either manually or just wait for all its retries to happen) until it’s “closed” and appears in red in the adminstrator “Services - Tasks” page.
6. Shutdown Lucee.
Here’s the fun part:
7. Start Lucee.
8. Go into the “Services - Tasks” admin page, note the closed ID = 1 red task is still there.
9. Create a new task thread.
The new task you created in step 9 will have ID = 1, just like the closed task does. If you click the detail button on either, you’ll see info from both on the same page, concatenated together. Not good.
This has got to be a bug, clearly the IDs should always be unique.
If you don’t stop/restart Lucee, this doesn’t happen. I suspect Lucee keeps track of the “next available ID” while it’s running, but forgets this value when it’s shutdown, and upon next start, I suspect Lucee checks all the OPEN tasks and selects the first free number, when instead it SHOULD be checking ALL tasks (both open and closed) and selecting the first free number (which, in this example, would result in a correct ID of 2).
User "cfmitrah" on dev.lucee.org verified the current version has this bug too, and asked me to open this ticket. URL over there is:
https://dev.lucee.org/t/bug-closed-task-thread-ids-reused-after-lucee-restart/8783
Thanks!