35 Commits

Author SHA1 Message Date
YueGuobin
59e5f8dd2f
Fix review issues: key_prefix length, count validation, WAL log, timeout comment, pointless temp var 2026-06-16 22:50:22 +08:00
YueGuobin
a8cc01af46
Remove database warmup (proven ineffective - real bottleneck was bcrypt blocking event loop) 2026-06-16 00:35:42 +08:00
YueGuobin
3c41dea48f
Replace SELECT 1 warmup with full database file read to warm OS page cache
Reading the entire DB file into OS page cache eliminates the 8-14s
cold-start penalty on the first ORM query (users/templates/api_keys).
Previous SELECT 1 only warmed the connection pool, not the file cache.
2026-06-15 23:43:41 +08:00
YueGuobin
e90fb0774c
Warm up database connection pool on startup to avoid 8s cold-start penalty on first API request 2026-06-15 23:26:28 +08:00
YueGuobin
6d3cfc7d1e
Fix: register WAL PRAGMA on sync_engine instead of Engine class for async compat
- Move event listener from module-level @Engine to engine.sync_engine
- Add WAL mode verification log on startup
- Remove unused Engine class-level listener
2026-06-15 23:21:50 +08:00
YueGuobin
49d2c271ca
Enable SQLite WAL mode to fix 'database is locked' errors under concurrent API requests 2026-06-15 13:02:17 +08:00
YueGuobin
b780bfaf53 feat(agent): refactor LLM configuration handling to use centralized config
- Replace separate user_id and jwt_token parameters with unified llm_config dict
- Simplify model factory to accept llm_config directly instead of fetching from API
- Update llm_call and generate_title nodes to extract llm_config from LangGraph config
- Remove deprecated API fetching logic from model factory
- Maintain backward compatibility for existing tool usage patterns

This change centralizes LLM configuration management, reducing API calls and improving performance by passing configuration directly from the API layer rather than fetching it repeatedly.
2026-03-04 13:13:54 +08:00
YueGuobin
8fad27d904 feat(db): improve database initialization and migration handling
- Add smarter database state detection during initialization to handle new databases, existing databases with new features, and old databases needing migration
- Make migration for llm_model_configs table idempotent to prevent conflicts when table already exists from code
- Add detailed logging for different database initialization scenarios
- Import sqlalchemy module for database inspection capabilities
2026-03-03 16:40:57 +08:00
Bine
4a059be480 Increase DB engine pool size and max overflow
As described in #2568 when multiple clients connect simultaneously, an excessive number of database pool connections are created. This leads to resource exhaustion and connection management issues.

We have introduced the pool_size and max_overflow parameters to better control the database connection pool.
These parameters ensure the database can handle a sufficient number of concurrent connections without over-allocating resources.

Added pool_size and max_overflow arguments to the database initialization.

This change overrides the default initialization configuration where the temporary fix was applied.

Co-Authored-By: Ufi <86113085+ufiking@users.noreply.github.com>
2025-10-17 22:17:10 +02:00
grossmj
4758431c76
Improvements for built-in disks
* Checksum is updated in the database for updated disks.
* It is not possible to prune them.
2025-01-02 23:10:51 +07:00
grossmj
b39c7541fb
Add timeout for waiting watchdog observer thread to complete 2024-12-31 17:24:19 +07:00
grossmj
82779d816f
Use watchdog instead of watchfiles to monitor for new images on the file system 2024-12-31 17:19:32 +07:00
grossmj
2718224dde
Increase SQLite timeout. Ref #2422 2024-10-31 21:31:03 +10:00
grossmj
9c456532d0 Pydantic v2 migration 2023-08-04 18:20:06 +10:00
grossmj
ab1f9a4385 Handle Alembic CommandError exceptions 2023-01-13 12:52:31 +08:00
grossmj
a033080418 Support for database schema migrations using alembic 2023-01-11 10:15:04 +08:00
grossmj
c6e31d98db Option to disable image discovery and do not scan parent directory 2022-12-26 12:32:40 +08:00
grossmj
725942157e Optionally allow Qemu raw images 2022-07-22 12:39:52 +02:00
Jeremy Grossmann
da626d334f
Merge branch '3.0' into iou-user-loader-libraries 2022-07-20 16:44:48 +02:00
grossmj
7f5ad8e225 Ignore image detection for IOU user libraries in image directory 2022-07-20 16:39:24 +02:00
grossmj
b2ba561c0d Only check files (not directories) when looking for new images on file system. 2022-07-16 12:11:26 +02:00
grossmj
30f7c0ce74 Fix issues when discovering images 2022-06-03 15:35:33 +07:00
Jeremy Grossmann
b94f01fe4e
Merge branch '3.0' into image-md5sum-management 2022-04-18 17:15:21 +07:00
grossmj
010d7aa49f Upgrade SQLAlchemy version and dispose of db engine 2022-04-17 17:32:44 +07:00
grossmj
e6c8144210 Detect new images added to the default image directory.
* Images can be present before the server starts or while it is running
* Images are recorded in the database
2022-04-17 16:58:20 +07:00
grossmj
10fdd8fcf4 Add connect endpoint for computes
Param to connect to compute after creation
Report compute unauthorized HTTP errors to client
2021-12-24 13:05:39 +10:30
grossmj
956b9056c1 Fix issues with latest version of sqlalchemy 2021-05-08 15:37:51 +09:30
grossmj
10164e262d Enable SQL foreign key support for SQLite 2021-05-06 17:21:45 +09:30
grossmj
c021e21309 Use black with -l 120 param. 2021-04-13 18:46:50 +09:30
grossmj
566e326b57 Save computes to database 2021-04-05 14:21:41 +09:30
grossmj
0fea3f969e Use aiosqlite and add service for templates 2021-03-28 21:17:29 +10:30
grossmj
d730c591b3 Refactor template management to use database. 2021-03-28 11:15:08 +10:30
grossmj
bde706d19a Generate JWT secret key if none is configured in the config file.
Change location of the database.
2020-12-16 18:24:21 +10:30
grossmj
d47dcb0d6f User authentication with tests. 2020-12-07 16:52:36 +10:30
grossmj
bf7cf862af Refactor tests and start work on database integration. 2020-12-02 18:39:08 +10:30