Skip to content

Commit d06f594

Browse files
committed
fix max_db_size issue in tests
1 parent ef7f496 commit d06f594

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

test/conftest.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ def init_movie_serial(conn: lb.Connection) -> None:
181181

182182

183183
_POOL_SIZE_: int = 256 * 1024 * 1024
184+
# Use 1GB max DB size for tests to avoid exhausting virtual address space
185+
# when many databases are open simultaneously (CI runners may have tight VA limits)
186+
_MAX_DB_SIZE_: int = 1 << 30
184187

185188

186189
def get_db_file_path(tmp_path: Path) -> Path:
@@ -228,7 +231,12 @@ def _close_cached_readonly_state() -> None:
228231

229232
def create_conn_db(path: Path, *, read_only: bool) -> ConnDB:
230233
"""Return a new connection and database."""
231-
db = lb.Database(path, buffer_pool_size=_POOL_SIZE_, read_only=read_only)
234+
db = lb.Database(
235+
path,
236+
buffer_pool_size=_POOL_SIZE_,
237+
read_only=read_only,
238+
max_db_size=_MAX_DB_SIZE_,
239+
)
232240
conn = lb.Connection(db, num_threads=4)
233241
return conn, db
234242

test/test_mvcc_bank.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,12 @@ def run_bank_test(
246246
edges = build_edges(N_ACCOUNTS, EDGE_PROB, rng)
247247

248248
try:
249-
db = lb.Database(str(db_path), enable_multi_writes=enable_multi_writes)
249+
db = lb.Database(
250+
str(db_path), enable_multi_writes=enable_multi_writes, max_db_size=1 << 30
251+
)
250252
except TypeError:
251253
# Fallback if binding patch is not applied
252-
db = lb.Database(str(db_path))
254+
db = lb.Database(str(db_path), max_db_size=1 << 30)
253255

254256
setup_db(db, N_ACCOUNTS, edges)
255257

test/test_wal.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def run_query_in_new_process(tmp_path: Path, build_dir: Path, queries: str):
1515
sys.path.append(r"{build_dir!s}")
1616
1717
import ladybug as lb
18-
db = lb.Database(r"{db_path!s}")
18+
db = lb.Database(r"{db_path!s}", max_db_size=1 << 30)
1919
""") + queries
2020
return subprocess.Popen([sys.executable, "-c", code])
2121

@@ -40,7 +40,7 @@ def test_replay_after_kill(tmp_path: Path, build_dir: Path) -> None:
4040
""")
4141
run_query_then_kill(tmp_path, build_dir, queries)
4242
db_path = get_db_file_path(tmp_path)
43-
with lb.Database(db_path) as db, lb.Connection(db) as conn:
43+
with lb.Database(db_path, max_db_size=1 << 30) as db, lb.Connection(db) as conn:
4444
# previously committed queries should be valid after replaying WAL
4545
result = conn.execute("CALL show_tables() RETURN *")
4646
assert result.has_next()
@@ -64,7 +64,7 @@ def test_replay_with_exception(tmp_path: Path, build_dir: Path) -> None:
6464
""")
6565
run_query_then_kill(tmp_path, build_dir, queries)
6666
db_path = get_db_file_path(tmp_path)
67-
with lb.Database(db_path) as db, lb.Connection(db) as conn:
67+
with lb.Database(db_path, max_db_size=1 << 30) as db, lb.Connection(db) as conn:
6868
# previously committed queries should be valid after replaying WAL
6969
result = conn.execute("match (t:tab) where t.id <= 5 return t.id")
7070
assert result.get_num_tuples() == 5

0 commit comments

Comments
 (0)