Serialization Error: The database file version is incompatible
DuckDB could not serialize data for a COPY, export or checkpoint, or a database file was written by an incompatible version.
- Exception
Serialization Error
它的意義
DuckDB database files record the storage version they were written with. A file written by a newer DuckDB cannot be opened by an older build. Since v0.10 the format is backwards compatible, so a current build reads files from older versions, but never the other way around.
The wording has changed across versions. Older builds print the classic Serialization Error: Loading a database file written by a different DuckDB version is not supported. DuckDB 2.x reports storage version numbers instead, for example IO Error: Trying to read a database file with version number 69, but we can only read versions between 64 and 68. A newer-feature file reports Serialization Error: Failed to deserialize: .... All of them mean the same mismatch between the build that wrote the file and the build that opened it.
常見原因
- An app or driver pinned to an older DuckDB opened a file that a newer tool, CLI or notebook wrote.
- Two machines, or a laptop and a container, share one file while running different DuckDB versions.
- A CI run wrote the file with the latest build and a deployment with an older library picked it up.
Find the cause
-- Run on both the connection that fails and the one that wrote the file:
SELECT version();
-- What storage version this build checkpoints as (DuckDB 2.x):
SELECT current_setting('storage_compatibility_version') AS written_as;
如何修正
-
Check the version of the build that fails, then upgrade it to at least the version that wrote the file:
SELECT version();
-
When both versions must stay, copy the data out with the newer build and load it with the older one:
COPY my_table TO 'my_table.parquet' (FORMAT PARQUET);
-
To keep sharing a file with older readers, a recent DuckDB can checkpoint against an older storage version:
ATTACH 'compat.duckdb' (STORAGE_VERSION 'v1.4.0');
Other ways to handle it
Parquet and CSV are the interchange formats between incompatible builds, and DuckDB reads both on every version. For teams that must share database files, agree on the oldest DuckDB version in play and pin everyone to it, or keep the shared data in files rather than in a database file.
安全地重現問題
-- Not reproducible inside one build: the mismatch happens when the file is opened. -- Check both sides of the handoff first: SELECT version();
問題
Can a newer DuckDB open a file from an older version?
Yes. Since v0.10 the storage format is backwards compatible, so current builds read files written by older versions.
How do I move a database to a machine that cannot be upgraded?
Export with the newer build as Parquet or CSV and load it there, or have the newer build write the file with an older storage version using ATTACH ... (STORAGE_VERSION ...).
相關錯誤
IO ErrorA file could not be openedIO ErrorThe database file is locked by another processSQLITE_ERRORSQLite: SQL logic error
程式碼和訊息文字來自 DuckDB documentation。瀏覽完整的 DuckDB error list 或 搜尋每個資料庫錯誤.
Work on DuckDB in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for DuckDB and the other databases you use.
本頁文字與資料: CC BY 4.0,請註明出處 SQLly (sqlly.app)。 程式碼與 SQL 片段: MIT. 授權詳情 引用的錯誤訊息文字歸其資料庫廠商所有。