RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix(db): make negative GET_LOCK timeouts work on MariaDB (#18529)
Christian Uhlf806001b3fa3
diff --git a/api/db/db_models.py b/api/db/db_models.pyindex 77ebcfc48f..5d03459cdb 100644--- a/api/db/db_models.py+++ b/api/db/db_models.py@@ -966,9 +966,17 @@ class GaussDBDatabaseLock(PostgresDatabaseLock):class MysqlDatabaseLock:+ # Finite wait used for negative advisory-lock timeouts.+ BLOCKING_TIMEOUT = 60+def __init__(self, lock_name, timeout=10, db=None):self.lock_name = lock_name- self.timeout = int(timeout)+ timeout = int(timeout)+ if timeout < 0:+ logging.debug("Normalizing negative advisory-lock timeout to %d seconds", self.BLOCKING_TIMEOUT)+ self.timeout = self.BLOCKING_TIMEOUT+ else:+ self.timeout = timeoutself.db = db if db else DB@with_retry(max_retries=3, retry_delay=1.0)diff --git a/test/unit_test/api/db/test_mysql_database_lock.py b/test/unit_test/api/db/test_mysql_database_lock.pynew file mode 100644index 0000000000..e2bc32adf1--- /dev/null+++ b/test/unit_test/api/db/test_mysql_database_lock.py@@ -0,0 +1,21 @@+"""+Tests for MySQL advisory lock timeouts.+"""++import pytest++from api.db.db_models import MysqlDatabaseLock+++class TestMysqlDatabaseLockTimeout:+ """Negative advisory-lock timeouts use a finite wait."""++ @pytest.mark.parametrize("timeout", [-1, -60])+ def test_negative_timeout_falls_back_to_blocking_timeout(self, timeout):+ lock = MysqlDatabaseLock("unit_test_lock", timeout)+ assert lock.timeout == MysqlDatabaseLock.BLOCKING_TIMEOUT++ @pytest.mark.parametrize("timeout", [0, 10, 60])+ def test_non_negative_timeout_is_preserved(self, timeout):+ lock = MysqlDatabaseLock("unit_test_lock", timeout)+ assert lock.timeout == timeout