mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-05-09 08:25:54 +02:00
[GH-ISSUE #897] [Bug]: Failed SQLite state updates create "ghost" jobs, causing UI to show false double-assignments #618
Labels
No labels
A1
automated
automated
bug
bug
Closed due to inactivity
contrib
dependencies
dependencies
duplicate
enhancement
feedback
hold
invalid
Notes
P1S
pull-request
security
ThumbsUp
user-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/bambuddy-maziggy-1#618
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @stringham on GitHub (Apr 5, 2026).
Original GitHub issue: https://github.com/maziggy/bambuddy/issues/897
Originally assigned to: @maziggy on GitHub.
Bug Description
When a print physically finishes, a background task attempts to update the job state in the database from
printingtocompleted. If this update fails due to an SQLite lock, the job becomes a "ghost" job permanently stuck in theprintingstate.When the user subsequently clears the build plate via the API, the queue dispatcher sees the physical hardware is ready and correctly dispatches the next job. However, because the previous job's state was never resolved, the database now has multiple jobs concurrently marked as
printingon the exact sameprinter_id. This causes the print queue to look like the printer has been double-assigned, even though physically only one job is running.Expected Behavior
Background tasks handling state changes (like print completion and runtime tracking) need retry logic if they hit an SQLite database is locked error. The database state must accurately reflect reality so that finished prints reliably transition out of the printing state.
Steps to Reproduce
Because this relies on a database concurrency lock, it is difficult to reproduce manually, but the sequence of events is:
Printer Model
P1S
Bambuddy Version
v0.2.2.2
Printer Firmware Version
01.09.01.00
Installation Method
Docker
Operating System
Linux (Ubuntu/Debian)
Relevant Logs / Support Package
I was able to track this exact sequence of events down in my database and application logs.
The False Double Assignment:
Job 287 successfully finished printing physically, but was never cleared from the database. When I cleared the plate roughly three hours later, Job 291 was correctly dispatched to the idle printer (Printer 1).
Querying the database for active jobs shows the ghost job collision:
select id, printer_id, target_model, archive_id, library_file_id, position, plate_id, status, started_at, created_at from print_queue where status="printing" order by id desc;printingprintingprintingprintingJob 291 is the new job actually printing, job 287 is the ghost job that is physically finished.
The Root Cause (SQLite Locks):
Checking the docker logs during the dispatch window reveals the background workers hitting OperationalError: database is locked exactly when state updates are attempting to process:
Path Extraction Errors:
During this same window, there is a recurring path parsing error. The system seems to be trying to extract print times by passing the root /app/data directory instead of a specific file path. I am not sure if this is contributing to the database lock or preventing job resolution, but it happens concurrently:
Screenshots
No response
Additional Context
No response
Checklist
@maziggy commented on GitHub (Apr 7, 2026):
Thank you very much for your investigations and this perfect bug report :)
@maziggy commented on GitHub (Apr 7, 2026):
Available/Fixed in branch dev and available with the next release or daily build. Please let me know if it works now.