diff -Nuar a/vendor/magento/framework/Lock/Backend/Database.php b/vendor/magento/framework/Lock/Backend/Database.php
--- a/vendor/magento/framework/Lock/Backend/Database.php
+++ b/vendor/magento/framework/Lock/Backend/Database.php
@@ -3,8 +3,8 @@
  * Copyright © Magento, Inc. All rights reserved.
  * See COPYING.txt for license details.
  */
-
 declare(strict_types=1);
+
 namespace Magento\Framework\Lock\Backend;
 
 use Magento\Framework\App\DeploymentConfig;
@@ -14,20 +14,44 @@ use Magento\Framework\Exception\AlreadyExistsException;
 use Magento\Framework\Exception\InputException;
 use Magento\Framework\Phrase;
 
+/**
+ * Implementation of the lock manager on the basis of MySQL.
+ */
 class Database implements \Magento\Framework\Lock\LockManagerInterface
 {
-    /** @var ResourceConnection */
+    /**
+     * Max time for lock is 1 week
+     *
+     * MariaDB does not support negative timeout value to get infinite timeout,
+     * so we set 1 week for lock timeout
+     */
+    const MAX_LOCK_TIME = 604800;
+
+    /**
+     * @var ResourceConnection
+     */
     private $resource;
 
-    /** @var DeploymentConfig */
+    /**
+     * @var DeploymentConfig
+     */
     private $deploymentConfig;
 
-    /** @var string Lock prefix */
+    /**
+     * @var string Lock prefix
+     */
     private $prefix;
 
-    /** @var string|false Holds current lock name if set, otherwise false */
+    /**
+     * @var string|false Holds current lock name if set, otherwise false
+     */
     private $currentLock = false;
 
+    /**
+     * @param ResourceConnection $resource
+     * @param DeploymentConfig $deploymentConfig
+     * @param string|null $prefix
+     */
     public function __construct(
         ResourceConnection $resource,
         DeploymentConfig $deploymentConfig,
@@ -46,9 +70,13 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
      * @return bool
      * @throws InputException
      * @throws AlreadyExistsException
+     * @throws \Zend_Db_Statement_Exception
      */
     public function lock(string $name, int $timeout = -1): bool
     {
+        if (!$this->deploymentConfig->isDbAvailable()) {
+            return true;
+        };
         $name = $this->addPrefix($name);
 
         /**
@@ -59,7 +87,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
         if ($this->currentLock) {
             throw new AlreadyExistsException(
                 new Phrase(
-                    'Current connection is already holding lock for $1, only single lock allowed',
+                    'Current connection is already holding lock for %1, only single lock allowed',
                     [$this->currentLock]
                 )
             );
@@ -67,7 +95,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
 
         $result = (bool)$this->resource->getConnection()->query(
             "SELECT GET_LOCK(?, ?);",
-            [(string)$name, (int)$timeout]
+            [$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout]
         )->fetchColumn();
 
         if ($result === true) {
@@ -83,9 +111,14 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
      * @param string $name lock name
      * @return bool
      * @throws InputException
+     * @throws \Zend_Db_Statement_Exception
      */
     public function unlock(string $name): bool
     {
+        if (!$this->deploymentConfig->isDbAvailable()) {
+            return true;
+        };
+
         $name = $this->addPrefix($name);
 
         $result = (bool)$this->resource->getConnection()->query(
@@ -106,14 +139,19 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
      * @param string $name lock name
      * @return bool
      * @throws InputException
+     * @throws \Zend_Db_Statement_Exception
      */
     public function isLocked(string $name): bool
     {
+        if (!$this->deploymentConfig->isDbAvailable()) {
+            return false;
+        };
+
         $name = $this->addPrefix($name);
 
         return (bool)$this->resource->getConnection()->query(
             "SELECT IS_USED_LOCK(?);",
-            [(string)$name]
+            [$name]
         )->fetchColumn();
     }
 
@@ -123,7 +161,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
      * Limited to 64 characters in MySQL.
      *
      * @param string $name
-     * @return string $name
+     * @return string
      * @throws InputException
      */
     private function addPrefix(string $name): string
