{"record":{"id":"18ce961de6daeca1","repo":"ocrmypdf/OCRmyPDF","slug":"a-worker-process-lost-access-to-an-input-file","errorCode":null,"errorMessage":"A worker process lost access to an input file","messagePattern":"A worker process lost access to an input file","errorType":"error_code","errorClass":"InputFileError","httpStatus":null,"severity":"critical","filePath":"src/ocrmypdf/builtin_plugins/concurrency.py","lineNumber":68,"sourceCode":"    https://docs.python.org/3/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes\n    \"\"\"\n    while True:\n        try:\n            record = q.get()\n            if record is None:\n                break\n            logger = logging.getLogger(record.name)\n            logger.handle(record)\n        except Exception:  # pylint: disable=broad-except\n            import traceback  # pylint: disable=import-outside-toplevel\n\n            print(\"Logging problem\", file=sys.stderr)\n            traceback.print_exc(file=sys.stderr)\n\n\ndef process_sigbus(*args):\n    \"\"\"Handle SIGBUS signal at the worker level.\"\"\"\n    raise InputFileError(\"A worker process lost access to an input file\")\n\n\ndef process_init(q: Queue, user_init: UserInit, loglevel) -> None:\n    \"\"\"Initialize a process pool worker.\"\"\"\n    # Ignore SIGINT (our parent process will kill us gracefully)\n    signal.signal(signal.SIGINT, signal.SIG_IGN)\n\n    # Install SIGBUS handler (so our parent process can abort somewhat gracefully)\n    with suppress(AttributeError):  # Windows and Cygwin do not have SIGBUS\n        # Windows and Cygwin do not have pthread_sigmask or SIGBUS\n        signal.signal(signal.SIGBUS, process_sigbus)\n\n    # Remove any log handlers inherited from the parent process\n    root = logging.getLogger()\n    remove_all_log_handlers(root)\n\n    # Set up our single log handler to forward messages to the parent\n    root.setLevel(loglevel)","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/ocrmypdf/OCRmyPDF/blob/5074a0b0e109362422b768fd271ed84bf717c4ec/src/ocrmypdf/builtin_plugins/concurrency.py#L50-L86","documentation":"In the multiprocessing executor, a SIGBUS signal handler installed in each worker raises InputFileError with this message. SIGBUS on Linux typically means a file backing the processing (input PDF or a temp/ramfs file) was truncated, deleted, or its filesystem ran out of space while a worker had it mapped or open.","triggerScenarios":"Running ocrmypdf with the standard process-pool concurrency when the input file (or a temp file under /tmp or TMPDIR) is removed/truncated mid-run, or disk/tmpfs space is exhausted.","commonSituations":"Cleaning tmp directories from another process during a long job, Docker containers with a small tmpfs, network filesystems dropping out, or oversubscribed RAM when tmpfs is used.","solutions":["Free space on the filesystem holding TMPDIR (often /tmp on tmpfs) and on the output volume; retry the job.","Ensure the input PDF is not modified/deleted while the job runs; keep it on local stable storage rather than a flaky network mount.","Set TMPDIR to a directory on a disk-backed filesystem with ample space; reduce --jobs if memory pressure is involved."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import shutil, os\nassert shutil.disk_usage(os.environ.get('TMPDIR','/tmp')).free > 1_000_000_000, 'low space in TMPDIR'","typeGuard":null,"tryCatchPattern":"from ocrmypdf.exceptions import InputFileError\ntry:\n    ocr(in_pdf, out_pdf)\nexcept InputFileError as e:\n    # worker lost access: free space / stabilize input, then retry once\n    cleanup_and_retry()","preventionTips":["Monitor free space on TMPDIR and output filesystem during long jobs.","Never delete or rewrite the input PDF while a job is running.","Prefer disk-backed TMPDIR over small tmpfs for large jobs."],"tags":["ocrmypdf","sigbus","multiprocessing","disk-full","temp-files"],"backgroundTag":"sigbus-input-file-lost","analyzedSha":"5074a0b0e109362422b768fd271ed84bf717c4ec","analyzedAt":"2026-08-27T11:57:38.523Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}