Uploaded image for project: 'Nuxeo Drive '
  1. Nuxeo Drive
  2. NXDRIVE-2657

Fix database is_healthy() check to ensure to close the connection

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 3.1.1
    • Fix Version/s: 5.2.2
    • Component/s: Framework

      Description

      Problem

      Sentry Issue: NUXEO-DRIVE-538

      [OS] Unable to restore C:\Users\USER\.nuxeo-drive\ndrive_ENGINE_UID.db
      
      OperationalError: disk I/O error
        File "nxdrive\engine\dao\sqlite.py", line 187, in __init__
        File "nxdrive\engine\dao\utils.py", line 70, in fix_db
        File "nxdrive\engine\dao\utils.py", line 21, in is_healthy
      
      PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\USER\\.nuxeo-drive\\ndrive_ENGINE_UID.db'
        File "nxdrive\engine\dao\sqlite.py", line 244, in restore_backup
        File "nxdrive\engine\dao\utils.py", line 132, in restore_backup
        File "pathlib.py", line 1343, in unlink
      

      Analysis

      A database cannot be restored when is_healthy() failed just before. Actually, the connection to the database is not automatically closed when an exception is raised during the operation, even with the use of the context manager.
      As the documentation states:

      Connection object used as context manager only commits or rollbacks transactions, so the connection object should be closed manually.

      Fix

      Ensure to close to close the connection on any error.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours
                  2h