mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-11-12 14:21:03 +08:00
### Summary The fix turns a negative timeout into a finite 60 second wait inside `MysqlDatabaseLock`, which both servers accept. Callers keep expressing "block until available", and the equivalent PostgreSQL and GaussDB work on the same `-1` semantics (#16346, #18506) is untouched. Non-negative timeouts keep their current behaviour. --------- Co-authored-by: Krim <git@krim.dev>
22 lines
681 B
Python
22 lines
681 B
Python
"""
|
|
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
|