Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: M4B Conversion via API does not check if a conversion is already in progress - Server Crash #3331

Closed
kuldan5853 opened this issue Aug 24, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@kuldan5853
Copy link

What happened?

If you use the API to initialize an M4B conversion of a library item, it does not check if the current item is already being encoded - if you send the request twice, ABS initializes ffmpeg twice, trying to access the same files (you can watch this very easily because both threads try to update the percentage done on the ABS interface), eventually crashing the server when the second thread tries to access the files.txt file locked by the first process.

This leads to a complete server crash.

What did you expect to happen?

The API should be thread aware and deny a request if an encoding is already in progress / just let the process continue instead of spawning a second encoder.

Steps to reproduce the issue

  1. Start encoding a Library item via the API
  2. Send the same command a second time while the encoding is ongoing

Audiobookshelf version

v2.12.3

How are you running audiobookshelf?

Windows Tray App

What OS is your Audiobookshelf server hosted from?

Windows

If the issue is being seen in the UI, what browsers are you seeing the problem on?

None

Logs

{"timestamp":"2024-08-21 14:13:25.661","source":"    at process.<anonymous> (C:\\snapshot\\audiobookshelf\\server\\Server.js)","message":"[Server] Unhandled rejection: Error: EBUSY: resource busy or locked, unlink 'C:\\Audiobookshelf\\Data\\metadata\\cache\\items\\402d7afe-6672-4524-9516-d70bd423c6bb\\files.txt', promise: Promise {\n  <rejected> [Error: EBUSY: resource busy or locked, unlink 'C:\\Audiobookshelf\\Data\\metadata\\cache\\items\\402d7afe-6672-4524-9516-d70bd423c6bb\\files.txt'] {\n    errno: -4082,\n    code: 'EBUSY',\n    syscall: 'unlink',\n    path: 'C:\\\\Audiobookshelf\\\\Data\\\\metadata\\\\cache\\\\items\\\\402d7afe-6672-4524-9516-d70bd423c6bb\\\\files.txt'\n  }\n}","levelName":"FATAL","level":5}

Additional Notes

No response

@kuldan5853 kuldan5853 added the bug Something isn't working label Aug 24, 2024
@kuldan5853
Copy link
Author

As a note - there is a docker tool on the docker hub called abs-autoconverter that uses the API to watch the library for multi-track files to automatically trigger a conversion to m4b using the API. This is run via cron at set intervals (since there seems to be no way in the API to check the progress of an encode), and if a book takes longer than expected to encode, the tool will send an encode request for the same book again and this will trigger the server trash.

@advplyr advplyr added the awaiting release Issue is resolved and will be in the next release label Aug 25, 2024
Copy link

Fixed in v2.13.0.

@github-actions github-actions bot removed the awaiting release Issue is resolved and will be in the next release label Aug 31, 2024
nichwall pushed a commit to nichwall/audiobookshelf that referenced this issue Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants