Repository navigation
feat: Serverless startup without data or network on the boot path - #209
Merged
Merged
Conversation
- G1 warm-up modes: ducklake.warmup / cache.warmup / CLI+env override, Unbuilt readiness state, cache_not_built, /health degraded - G2 extensions: duckdb.default-extensions, FLAPI_EXTENSION_DIRECTORY, FLAPI_EXTENSIONS_OFFLINE fail-fast, flapi extensions install helpers - G4a ducklake.read-only: READ_ONLY attach, no maintenance, 409 on mutations - G6 flapi cache refresh one-shot command - Stubs only (declarations, TODO bodies) so the suite compiles and fails on assertions; implementation follows in the green commit - Integration: test_serverless_startup.py + offline fixture
- CONFIG_REFERENCE: duckdb.default-extensions, ducklake.warmup, ducklake.read-only, cache.warmup, cache_not_built - CLI_REFERENCE: --cache-warmup/--no-cache-warmup, flapi cache refresh, flapi extensions install, new env vars, unbuilt on /health - New guide docs/guides/serverless.md; DESIGN_DECISIONS section 11; caching spec readiness states; CHANGELOG - Dockerfile runtime target with pre-installed extensions; CI builds and publishes :<tag>-runtime and checks it starts with --network none
- The mock adapter returns QueryResult by value; query_executor.hpp was missing, so the test did not compile - Mirror cache_manager_test.cpp's STL pre-include list for the private-to-public include hack
…een) - G1: ducklake.warmup always|if-empty|never, cache.warmup, --cache-warmup, --no-cache-warmup, FLAPI_CACHE_WARMUP; Unbuilt readiness state answers 503 cache_not_built, /health 200 degraded with an unbuilt list - G2: duckdb.default-extensions list, FLAPI_EXTENSION_DIRECTORY, FLAPI_EXTENSIONS_OFFLINE (no INSTALL, autoinstall off, fail fast naming the missing extensions), flapi extensions install subcommand - G2 finding: flAPI's DuckDB loads no extension statically, so core_functions was silently downloaded on the first query of every fresh container; it is now always collected, installed in the runtime image, and checked explicitly offline (extensions now load before the version query) - G4a: ducklake.read-only attaches READ_ONLY, forces warm-up never, skips audit DDL, scheduled refresh, retention and compaction; config service answers 409 read_only_cache to refresh, update and GC - G6: flapi cache refresh (--endpoint ... | --all) refreshes once, prints a JSON summary, exits 0/1/2 - Tests: 20 new C++ cases and 6 integration tests pass; full C++ suite (829 cases) and 454 standalone integration tests pass
- DuckLake does not create the catalog's parent directory, so the runtime-image CI check would fail in a fresh container - Verified locally: pre-seeded extensions, FLAPI_EXTENSIONS_OFFLINE=1 and a dead proxy start live in 2 s and serve the cached endpoint
- flapi pack --with-extensions installs the config's extensions (core_functions, duckdb.default-extensions, connection INSTALLs) for the host platform and embeds them under the reserved .flapi/extensions/ prefix; --extensions-dir embeds an already filled directory (other platforms) - At startup the bundle's extensions are extracted once to $TMPDIR/flapi-extensions/ext-<content hash>/ (staged + renamed, reused on restart, entries escaping the directory refused), dropped from the in-memory bundle map, used as extension_directory, and offline extensions default on; precedence config > FLAPI_EXTENSION_DIRECTORY > bundle, FLAPI_EXTENSIONS_OFFLINE=0 overrides - An input tree may not use .flapi/ itself - Tests first: pack_test (embed, reserved prefix, missing dir) and bundled_extensions_test failed against stubs, now pass; integration test packs the fixture and runs the binary from an empty directory with no network - Full C++ suite 837 cases pass; docs: CLI_REFERENCE pack options, guide, DESIGN_DECISIONS, CHANGELOG, CLAUDE.md
- main.cpp called ::getpid() although its <unistd.h> include is POSIX-only; extension_installer.cpp included <unistd.h> unguarded - Add CurrentProcessId() (getpid / _getpid) and use it in pack, bundle extraction and the DuckLake reader test - extension_installer_test and bundled_extensions_test use the repo's existing _putenv_s shim for setenv/unsetenv on Windows
- osx-universal-build failed to compile bundled_extensions_test.cpp: on libc++ std::filesystem::file_time_type has an __int128 duration, which Catch2 cannot stringify when it decomposes REQUIRE(a == b) - Compare first, assert the bool; the check itself is unchanged
- docker-build's offline start check ran the /dev/tcp probe through sh,
which in ubuntu:24.04 is dash and has no /dev/tcp; the probe could never
connect and the step failed after 30 s although the container was up
(log: 8/8 extensions loaded offline, cache warmed)
- Reproduced locally: dash reports 'cannot create /dev/tcp/...', bash gets
{"status":"live"} from the same listener
2 of 3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A review of a Cloud Run migration found its 6–17 min cold starts, multi-GiB containers and 20 min deploys came mostly from usage: every scale-to-zero instance filled the per-instance cache from BigQuery at boot. It also found real flAPI gaps. This PR makes everything on the boot path optional, with every default unchanged:
ducklake.warmup: always | if-empty | never, per-endpointcache.warmup,--cache-warmup/--no-cache-warmup/FLAPI_CACHE_WARMUP. A skipped cache with no table is unbuilt: its endpoint answers503 cache_not_built;/healthanswers200 degradedwith anunbuiltlist.duckdb.default-extensions(was hard-coded) andFLAPI_EXTENSION_DIRECTORY.FLAPI_EXTENSIONS_OFFLINE=1(fail fast instead of downloading).flapi extensions installfor image builds.core_functionswas downloaded on the first query of every fresh container. It is now always installed and checked offline.Dockerfileruntimetarget, published as:<tag>-runtime(:lateststays slim). CI checks that it starts with--network none.flapi pack --with-extensions(or--extensions-dir): the packed binary carries its extensions under.flapi/extensions/, extracts them once (content-addressed) and starts offline.ducklake.read-only: trueattachesREAD_ONLY, forces warm-upnever, and runs no refresh, retention or compaction. Cache mutations through the config service get409.flapi cache refresh (--endpoint … | --all)refreshes once, prints JSON and exits 0/1/2. Run it as a job afterdbt buildinstead of an always-on writer.docs/guides/serverless.md.Decisions taken:
/healthreports unbuilt as200 degraded, the same asstale.-runtimetag, plus pack embedding.Test plan
Written test-first. The red commits/runs failed on assertions against stubs; the green commits pass.
cache_warmup_mode_test.cppextension_installer_test.cppducklake_reader_test.cpp(real writer job + read-only reader on one DuckLake catalog)bundled_extensions_test.cpppack_test.cpptest_serverless_startup.py(8), against the real binary:--no-cache-warmupgives degraded/healthandcache_not_built;if-emptyserver serving without rebuilding;-runtimeimage build and its--network nonestart check run in CI only. Not run locally (no Docker daemon).Closes #201
Closes #202
Closes #203
Closes #204
Closes #205
Closes #206
Closes #207
Generated by Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.