Skip to content

[bug] AssertionError: Conan failed to acquire database lock #19181

@Alexolut

Description

@Alexolut

Describe the bug

Windows Server 2022, Conan 2.22.1, Python 3.11

The problem arises after upgrade Conan from 2.21.0 to 2.22.0 (and 2.22.1) on our CI workflow during conan install packages. It's not quite stable fail, sometimes it works as expected. Below you can find logs (some parts are truncated for brevity):

Run py -3 -m pip install conan==2.22.1
Collecting conan==2.22.1
  Downloading conan-2.22.1.tar.gz (542 kB)
     -------------------------------------- 542.4/542.4 kB 3.8 MB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: requests<3.0.0,>=2.25 in c:\python311\lib\site-packages (from conan==2.22.1) (2.32.4)
Requirement already satisfied: urllib3<3.0,>=1.26.6 in c:\python311\lib\site-packages (from conan==2.22.1) (1.26.20)
Requirement already satisfied: colorama<0.5.0,>=0.4.3 in c:\python311\lib\site-packages (from conan==2.22.1) (0.4.6)
Requirement already satisfied: PyYAML<7.0,>=6.0 in c:\python311\lib\site-packages (from conan==2.22.1) (6.0.2)
Collecting patch-ng<1.19,>=1.18.0 (from conan==2.22.1)
  Downloading patch-ng-1.18.1.tar.gz (17 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: fasteners>=0.15 in c:\python311\lib\site-packages (from conan==2.22.1) (0.19)
Requirement already satisfied: Jinja2<4.0.0,>=3.0 in c:\python311\lib\site-packages (from conan==2.22.1) (3.1.6)
Requirement already satisfied: python-dateutil<3,>=2.8.0 in c:\python311\lib\site-packages (from conan==2.22.1) (2.9.0.post0)
Requirement already satisfied: MarkupSafe>=2.0 in c:\python311\lib\site-packages (from Jinja2<4.0.0,>=3.0->conan==2.22.1) (3.0.2)
Requirement already satisfied: six>=1.5 in c:\python311\lib\site-packages (from python-dateutil<3,>=2.8.0->conan==2.22.1) (1.16.0)
Requirement already satisfied: charset_normalizer<4,>=2 in c:\python311\lib\site-packages (from requests<3.0.0,>=2.25->conan==2.22.1) (3.4.2)
Requirement already satisfied: idna<4,>=2.5 in c:\python311\lib\site-packages (from requests<3.0.0,>=2.25->conan==2.22.1) (3.10)
Requirement already satisfied: certifi>=2017.4.17 in c:\python311\lib\site-packages (from requests<3.0.0,>=2.25->conan==2.22.1) (2025.7.14)
Building wheels for collected packages: conan, patch-ng
  Building wheel for conan (pyproject.toml): started
  Building wheel for conan (pyproject.toml): finished with status 'done'
  Created wheel for conan: filename=conan-2.22.1-py3-none-any.whl size=682077 sha256=4390d9d82d06611c2acd6e87abcd7927a05efd5e4e740782616012df23e02704
  Stored in directory: c:\users\gh-ci\appdata\local\pip\cache\wheels\59\1b\43\6502c708257c50b84469763d7f15a80db57489b28b5c5c3db7
  Building wheel for patch-ng (pyproject.toml): started
  Building wheel for patch-ng (pyproject.toml): finished with status 'done'
  Created wheel for patch-ng: filename=patch_ng-1.18.1-py3-none-any.whl size=17028 sha256=cdc3c7269eeb25b966e061f19daf34445608598f14f8bc54b57b3127a51b1f1a
  Stored in directory: c:\users\gh-ci\appdata\local\pip\cache\wheels\7b\cc\49\8bc9f301f7969862da20988c1bd25c60f20df61718a01b2449
Successfully built conan patch-ng
Installing collected packages: patch-ng, conan
  Attempting uninstall: patch-ng
    Found existing installation: patch-ng 1.17.4
    Uninstalling patch-ng-1.17.4:
      Successfully uninstalled patch-ng-1.17.4
  Attempting uninstall: conan
    Found existing installation: conan 1.61.0
    Uninstalling conan-1.61.0:
      Successfully uninstalled conan-1.61.0
Successfully installed conan-2.22.1 patch-ng-1.18.1

Notice:  A new release of pip is available: 23.2.1 -> 25.3
Notice:  To update, run: python.exe -m pip install --upgrade pip

....

======== Installing packages ========

-------- Downloading 95 packages --------
Downloading binary packages in 16 parallel threads


....



ERROR: Traceback (most recent call last):
  File "C:\Python311\Lib\site-packages\conan\cli\cli.py", line 297, in main
    cli.run(args)
  File "C:\Python311\Lib\site-packages\conan\cli\cli.py", line 193, in run
    command.run(self._conan_api, args[0][1:])
  File "C:\Python311\Lib\site-packages\conan\cli\command.py", line 191, in run
    info = self._method(conan_api, parser, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\conan\cli\commands\install.py", line 75, in install
    conan_api.install.install_binaries(deps_graph=deps_graph, remotes=remotes)
  File "C:\Python311\Lib\site-packages\conan\api\subapi\install.py", line 30, in install_binaries
    installer.install(deps_graph, remotes, install_order=install_order)
  File "C:\Python311\Lib\site-packages\conan\internal\graph\installer.py", line 255, in install
    self._download_bulk(install_order)
  File "C:\Python311\Lib\site-packages\conan\internal\graph\installer.py", line 286, in _download_bulk
    thread_pool.map(self._download_pkg, downloads)
  File "C:\Python311\Lib\multiprocessing\pool.py", line 367, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\multiprocessing\pool.py", line 774, in get
    raise self._value
  File "C:\Python311\Lib\multiprocessing\pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\multiprocessing\pool.py", line 48, in mapstar
    return list(map(*args))
           ^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\conan\internal\graph\installer.py", line 297, in _download_pkg
    self._remote_manager.get_package(node.pref, node.binary_remote)
  File "C:\Python311\Lib\site-packages\conan\internal\rest\remote_manager.py", line 142, in get_package
    pkg_layout = self._cache.create_pkg_layout(pref)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\conan\internal\cache\cache.py", line 161, in create_pkg_layout
    self._db.create_package(package_path, pref, None)
  File "C:\Python311\Lib\site-packages\conan\internal\cache\db\cache_database.py", line 87, in create_package
    self._packages.create(path, ref, build_id=build_id)
  File "C:\Python311\Lib\site-packages\conan\internal\cache\db\packages_table.py", line 80, in create
    with self.db_connection() as conn:
  File "C:\Python311\Lib\contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\conan\internal\cache\db\table.py", line 26, in db_connection
    assert self._lock.acquire(timeout=20), "Conan failed to acquire database lock"
AssertionError: Conan failed to acquire database lock

ERROR: Conan failed to acquire database lock

It seems highly likely related to parallel download, that is used by default since 2.22 (#19099). I noticed similar fails before on 2.21 when I was experimenting with --core-conf core.download:parallel={os.cpu_count()} for conan install command.

If it's necessary to provide additional details to simplify investigation, please let me know.

I found old similar bug that is marked as fixed: #13924

BTW: Will downloading work in single-thread mode if I add --core-conf core.download:parallel=1? Instead if I'm not able to disable parallel download we will stuck on 2.21 version, due to that error with database lock.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions