mirror of
https://github.com/simonw/datasette.git
synced 2026-11-24 10:59:37 +01:00
Merge spike/schema-watcher into spike/integrated, reconciling the three spikes
Read path: the leased pool replaces the thread-local cache. Pooled connections record Database._conn_generation when opened; a stale one is discarded on checkout or return, and _invalidate_connections() (called by the SchemaWatcher on a replaced/deleted file) closes that database's idle connections at once. Leased ones are only ever closed by their own thread on release. Write path: the idle-exit write thread keeps its lock protocol; its connection lives in a _WriteConnection holder that is reopened when the generation moves, before the next task. Post-write schema_version check and _after_write catalog await are kept for every write API in both modes. Non-threaded write connections are reopened on a generation change and never cached half-prepared. Deleted files: write connections use mode=rw once Datasette has seen the file exist (_file_seen), so a deleted file is never silently recreated, while a database added before its file exists is still created by its first write. Settings: max_open_connections (clamped to >= 4 x num_sql_threads), connection_idle_timeout_ms (30000, read connections and write threads), schema_watch_interval_ms, default_schema_watch (external|owned). The spike-only knobs (connection_idle_timeout, connection_pool_wait_ms, pool_read_connections, write_thread_idle_timeout_ms) are gone, along with the pool's wait/disable code paths. The reaper falls back to checkout-time reaping where threads cannot be started (Pyodide). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EwkLo2rJWidpkDVT3HkvNv
This commit is contained in:
commit
990c8782db
17 changed files with 2508 additions and 440 deletions
|
|
@ -760,10 +760,9 @@ async def test_settings_json(ds_client):
|
|||
"default_cache_ttl": 5,
|
||||
"num_sql_threads": 1,
|
||||
"max_open_connections": 128,
|
||||
"connection_idle_timeout": 60,
|
||||
"connection_pool_wait_ms": 0,
|
||||
"pool_read_connections": True,
|
||||
"write_thread_idle_timeout_ms": 30000,
|
||||
"connection_idle_timeout_ms": 30000,
|
||||
"schema_watch_interval_ms": 1000,
|
||||
"default_schema_watch": "external",
|
||||
"cache_size_kb": 0,
|
||||
"allow_csv_stream": True,
|
||||
"max_csv_mb": 100,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue