database-lab-engine

postgres-aiApache-2.0活跃维护

给 Postgres 数据库做分支和秒级瘦克隆,让 CI/CD 里的数据库测试跑得更快、成本更低。

DBLab enables 🖖 database branching and ⚡️ thin cloning for any Postgres database and empowers DB testing in CI/CD. This optimizes database-related costs while improving time-to-market and software quality. Follow to stay updated.

v4.2.1发布于 2026-10-08 14:02 UTC2,794star +8 / 7 天90fork同步于 2026-11-10 05:42 UTC

怎么上手

由 README 提炼,执行前请确认
README 未给出可直接复制的最小安装命令,仅指向教程:https://postgres.ai/docs/tutorials/database-lab-tutorial
硬件要求按 README 说明

README 未说明具体显存或 CPU 要求;薄克隆依赖 ZFS(默认)或 LVM,源数据库本身不需要 ZFS 或 Docker。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

给任意 PostgreSQL 做秒级薄克隆和数据库分支,用于开发测试与 CI/CD

给 Postgres 数据库做分支和秒级瘦克隆,让 CI/CD 里的数据库测试跑得更快、成本更低。

核心能力

  • 基于 ZFS/LVM 的 Copy-on-Write 实现秒级薄克隆
  • 支持物理(pg_basebackup、WAL-G、pgBackRest)与逻辑(dump/restore)两种数据获取
  • 提供 UI、API 与 CLI 三种操作方式,组件全部打包为 Docker 容器
  • 支持克隆、分支、快照的保留策略与删除保护
  • 单个克隆可用 pg_upgrade --link 原地升级 PostgreSQL 大版本

容易踩的坑

薄克隆依赖 ZFS 或 LVM,宿主机需提前准备对应存储;托管云数据库(如 AWS RDS、Heroku)无法直接物理连接,需在同区域单独 VM 上运行 DBLab 并定期自动刷新数据;社区版需按教程安装,商业版 DBLab SE 需通过 Postgres.ai Console 或 AWS Marketplace 部署。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v4.2.1
  1. v4.2.1最新正式版2026-10-08 · 2026-10-08 14:02 UTC

    Improvements and Fixes

    • Clone major upgrade no longer fails at the check stage on instances that mount TLS certificates or other files into clones: the upgrade container now gets the volumes from databaseContainer.containerConfig (!1206, #792)
    • The "Upgrade clone" button stays visible when clone upgrade is unavailable (for example, provision.pgUpgradeImage is not set); it is disabled and shows the engine's reason in a tooltip (!1205)
    • Creating a clone for a restricted user no longer fails with cannot alter partition ... with an incomplete detach when the snapshot holds a partition with a pending DETACH PARTITION ... CONCURRENTLY; the detach is finalized in the clone (!1208, #795)
    • Clone state (sessions.json) is written atomically, and the engine refuses to start on an unreadable state file; a crash in the middle of a write could previously lead to every clone being destroyed on the next start (!1198, #783)
    • A panic in a background job or an HTTP handler no longer terminates the engine, and data races in WebSocket token cleanup and webhook reload are fixed (!1198, !1199, #783, #784)
    • Config reload is synchronized across engine services, fixing data races between a reload and in-flight requests; two concurrent full refreshes can no longer both start, and a clone being provisioned keeps its database config across a reload (!1202, #788)
    • A rotated verificationToken takes effect on config reload instead of requiring a restart (!1199, #29)
    • A Postgres start timeout is reported as an error instead of success, and POST /observation/stop no longer hangs when the observation session ended with an error (!1199, #784)
    • The pool is activated and branching is initialized when there are no retrieval jobs or the snapshot already exists (!1199, #784)
    • --extra-config and --tags values without = make dblab return an error instead of panicking (!1199, #784)
    • Not-found and bad-request API errors return 404/400 instead of 500; percent-encoded snapshot IDs are accepted; POST /snapshot returns the snapshot model with correct sizes; an empty deleteAt is rejected with 400; the log of a branch named snapshot is reachable (!1197, #782)
    • The OpenAPI spec matches the engine's routes and models, including 7 previously undocumented operations (!1196)
    • The Logs tab no longer leaks WebSocket connections and auto-scrolls again, and a render error shows a message instead of a blan
  2. v4.2.02026-09-11 · 2026-09-11 02:54 UTC
    查看更新说明

    New Features

    • Simplified install: the UI Configuration tab opens in a new Simple mode — paste a source connection URL and password, and the engine detects the provider (RDS, Aurora, Heroku, Supabase and others), Postgres image and tag, databases, shared_buffers, shared_preload_libraries and query-tuning parameters, then applies the proposed config; Expert mode keeps full control and adds WAL-G and pgBackRest physical-mode fields (!1148, #713)
    • CLI: new dblab local-install command runs the same source detection and applies the proposed logical-mode config from the terminal (!1148, !1192, #774)
    • Clone major upgrade: upgrade an existing clone to a newer PostgreSQL major version in place with pg_upgrade --link, via POST /clone/{id}/upgrade, dblab clone upgrade or the UI; the target version comes from the configured provision.pgUpgradeImage and is reported on /status, and resetting the clone rolls it back (!1180, !1188, #756, #768)
    • Deletion protection and auto-deletion for branches and snapshots: protect a branch or snapshot forever or for a set duration, and let the new retention config section delete unused ones after N minutes (safe-only: anything with clones, children or protection is never removed); new PATCH /branch/{name} and PATCH /snapshot/{id} endpoints and --protected options in dblab branch and dblab snapshot update (!1161, !1166, !1171, #727, #735, #742)
    • Configs: whole-value ${VAR} / $VAR environment placeholders are expanded in engine, CI checker and CLI configs, including retrieval job options such as source passwords and S3, WAL-G and pgBackRest credentials, so secrets no longer have to be stored in plain text (!1140, !1178, #750)
    • Retrieval: new customOptions for WAL-G and pgBackRest physical restore passes extra tool flags (for example --restore-spec or --mask) without switching to customTool (!1182, #760)
    • Teleport (Standard and Enterprise Editions): opt-in platform.bindClonesToUser labels each clone with its owner (dblab_user), so Teleport db_labels rules can limit users to their own clones; covers clones created with a personal token and from the Platform console (!1163, !1173, #731)
    • Teleport: attach custom labels to sidecar db/app resources with the repeatable --label key=value flag or TELEPORT_LABELS; instance ownership moves to a dedicated dblab_instance label (!1162, [#730](https://gitlab.com/po
  3. v4.1.42026-09-01 · 2026-09-01 09:28 UTC
    查看更新说明

    Security

    • Engine: bump the Go toolchain to 1.26.7 and golang.org/x/mod to v0.40.0, and digest-pin the rds-refresh Alpine base image (!1183)
    • Engine: bump golang.org/x/crypto to v0.55.0 (!1184)
    • Engine: track the docker-cli 29.x series instead of an exact -rN pin, so image rebuilds pick up upstream security releases (!1152, !1186)
    • CE UI: bump cypress to 15.x, which drops the extract-zip and enquirer advisories that had no upstream fix (!1184)
    • CE UI: refresh the pnpm overrides for dompurify, qs, nanoid and @babel/core (!1184)
    • CE UI: add the postcss, brace-expansion, form-data, tmp, fast-uri, immutable, js-yaml and ws overrides (!1186)
    • CE UI: pin vite to 6.4.3, fixing a server.fs.deny bypass and an NTLMv2 hash disclosure through launch-editor (!1186)

    Internal

    • CI: install google-cloud-cli instead of the retired google-cloud-sdk package, which no longer resolves on Debian trixie (!1183)

    Full diff

    Diff between versions 4.1.3 and 4.1.4

  4. v4.1.32026-05-08 · 2026-05-08 12:53 UTC
    查看更新说明

    Security

    • Engine: trim Docker runtime image payloads to reduce CVE surface (!1144, #709)
    • CE UI: bump uuid and marked to fix dependency CVEs (!1142)

    Full diff

    Diff between versions 4.1.2 and 4.1.3

  5. v4.1.22026-04-29 · 2026-04-29 10:26 UTC
    查看更新说明

    Security

    • CE UI: refresh Alpine packages in run stage to clear OS CVEs (!1141)

    Full diff

    Diff between versions 4.1.1 and 4.1.2

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译


    *For managed PostgreSQL cloud services like AWS RDS or Heroku, direct physical connection and PGDATA access aren't possible. In these cases, DBLab should run on a separate VM within the same region. It will routinely auto-refresh its data, effectively acting as a database-as-a-service solution. This setup then offers thin database branching ideal for development and testing.

    Why DBLab?

    • Build dev/QA/staging environments using full-scale, production-like databases.
    • Provide temporary full-size database clones for SQL query analysis and optimization (see also: SQL optimization chatbot Joe).
    • Automatically test database changes in CI/CD pipelines, minimizing risks of production incidents.
    • Rapidly validate ChatGPT or other LLM concepts, check for hallucinations, and iterate towards effective solutions.

    For example, cloning a 1 TiB PostgreSQL database takes just about 10 seconds. On a single machine, you can have dozens of independent clones running simultaneously, supporting extensive development and testing activities without any added hardware costs.

    Try it yourself right now:

    How it works

    Thin cloning is fast because it is based on Copy-on-Write (CoW). DBLab employs two technologies for enabling thin cloning: ZFS (default) and LVM.

    Using ZFS, DBLab routinely takes new snapshots of the data directory, managing a collection of them and removing old or unused ones. When requesting a fresh clone, users have the option to select their preferred snapshot.

    Read more:

    Where to start

    Case studies

    Features

    • Speed & scale
      • Blazing-fast cloning of PostgreSQL databases – clone in seconds, irrespective of database size
      • Theoretical max of snapshots/clones: 264 (ZFS, default)
      • Maximum size of PostgreSQL data directory: 256 quadrillion zebibytes, or 2128 bytes (ZFS, default)
    • Support & technologies
      • Supported PostgreSQL versions: 10–18
      • Thin cloning (CoW) technologies: ZFS and LVM
      • UI for manual tasks and API & CLI for automation
      • Packaged in Docker containers for all components
    • PostgreSQL containers
      • Popular extensions including contrib modules, pgvector, HypoPG and many others (docs)
      • Customization capabilities for containers (docs)
      • Docker container and PostgreSQL configuration parameters in the DBLab config
    • Source database requirements
      • Location flexibility: self-managed PostgreSQL, AWS RDS, GCP Cloud SQL, Azure, etc.—no source adjustments needed.
      • No ZFS or Docker requirements for source databases
    • Data provisioning & retrieval
      • Simple-mode setup: paste source URL + password, get a probed configuration in one click (UI Configuration → Simple tab)
      • Expert-mode form for both logical (dump/restore) and physical (WAL-G, pgBackRest) retrieval
      • Physical (pg_basebackup, WAL-G, pgBackRest) and logical (dump/restore) provisioning
      • Partial data retrieval in logical mode (specific databases/tables)
      • Database renaming during snapshot creation (databaseRename option)
      • Continuous update in physical mode
      • Periodic full refresh in logical mode without downtime
    • Recovery & management
      • Fast Point in Time Recovery (PITR) for physical mode
      • Auto-deletion of unused clones
      • Time-based auto-deletion of unused branches and snapshots (retention config; safe-only, never force-deletes dependents)
      • Snapshot retention policies in DBLab configuration
    • Clones, branches & snapshots
      • "Deletion protection" for clones, branches, and snapshots (blocks manual and auto-deletion, plus count-based retention for snapshots)
      • Persistent clones withstand DBLab restarts
      • "Reset" command for data version switching
      • "Upgrade" command to move a single clone to a newer PostgreSQL major version in place
      • Resource quotas: CPU, RAM
    • Monitoring & security
      • /healthz API endpoint (no auth), extended /status endpoint (API docs)
      • Prometheus metrics endpoint (/metrics) for monitoring
      • Netdata module for insights

    Clone major upgrade

    A single clone can be moved to a newer PostgreSQL major version without touching the rest of the instance, which makes it practical to test an upgrade against production-like data:

    dblab clone upgrade my-clone
    

    The target version is not a parameter: it follows from the upgrade image the instance is configured with, which is built on that major's binaries. The engine reports it in GET /status as cloneUpgrade.targetVersion, the CLI prints it, and the UI shows it on the confirmation dialog.

    The same action is available in the UI on the clone page and over the API as POST /clone/{id}/upgrade.

    The clone's Postgres is shut down cleanly, pg_upgrade --link converts its data directory in place, and the clone restarts on an image of the target major. Because --link hard-links the data files instead of copying them, the upgrade is fast and consumes almost no extra space. The request returns as soon as the clone enters the UPGRADING state; watch the clone status for the result.

    Enabling it. Set provision.pgUpgradeImage to an upgrade image of the major you want clones upgraded to. That image is the single source of the target: the engine reads the major out of a release tag (:17, :17-0.8.0, :17-0.8.0-glibc236), and re-reads it from the image's own PG_MAJOR before every upgrade, so a tag repointed at another build is caught before any data moves. A tag outside that grammar — a digest pin, latest, a CI build — states no major, so the engine fetches the image in the background at startup and reads it from there; until that lands the upgrade reports itself unavailable. When pgUpgradeImage is unset the feature is simply unavailable and the endpoint says so; nothing else about the instance changes. The UI keeps the "Upgrade clone" button visible but disabled in that state, and its tooltip carries the reason reported on /status, so an unset image is one hover away from being diagnosed.

    provision:
      pgUpgradeImage: "postgresai/pg-upgrade:17"
      pgUpgradeTimeout: 3h
      pgUpgradePullTimeout: 1h
    

    pgUpgradeTimeout bounds a single upgrade run; it defaults to three hours. When the budget runs out, the upgrade container is removed and the clone is put back on the version its data directory still holds, exactly as it would be after any other failure.

    pgUpgradePullTimeout bounds each of the two image pulls that precede it, and defaults to one hour. The upgrade image carries the target major plus the server packages of the four preceding ones, so the first upgrade on an instance downloads several gigabytes; pre-pulling both images makes the step a no-op. Both pulls happen while the clone is still serving traffic, so exceeding the budget leaves the clone untouched and running. The two budgets are separate on purpose — a slow pull must not eat into the time pg_upgrade gets once the clone is already stopped.

    An upgrade request may name an image explicitly instead of letting the engine substitute the major in the current tag. provision.upgradeImageAllowList says which repositories such a request may name. When it is empty, as it is by default, only the repository of the clone image is accepted: the one databaseContainer.dockerImage points at, plus the repository of the clone's own image when the clone has already been upgraded to another one. That default accepts exactly the image the engine would derive itself. List repositories to allow other ones, or "*" to allow any repository the instance can reach.

    provision:
      upgradeImageAllowList:
        - "postgresai/extended-postgres"
    

    Releases up to v4.2.0 accepted any repository when the list was empty. An instance that relied on that must now set the list to ["*"].

    How it can end. Almost every outcome leaves the clone running:

    StatusMeaning
    OKThe clone runs the target version; dbVersion reports it.
    WARNINGThe upgrade was not applied. Either nothing had been converted and the clone still runs its original version, or conversion had begun and the clone was rebuilt from its origin snapshot — in which case data written since the clone was created is lost. The message says which, and points at the pg_upgrade log under <clone dir>/upgrade/logs/. When the postmaster that pg_upgrade started failed, its own fatal error, with the DETAIL and HINT lines that follow it, is appended to the cause, and the run's pg_upgrade_output.d/<timestamp>/ directory (server log, internal log, schema dumps) is preserved under the same logs/ directory; the five most recent failed runs are kept.
    WARNING, clone not runningThe upgrade settled on disk but the clone container did not come back up. The data directory is intact and the upgrade is still recorded as pending, so the next engine start finishes or undoes it and brings the clone back.
    FATALRecovery itself failed and there is nothing left to finish. Reset or delete the clone.

    Rolling back. Resetting the clone returns it to the version the instance is configured with, because a reset re-provisions from the origin snapshot using the engine-wide image.

    Things to know.

    • The target must be newer than the clone's current major and at most four majors ahead — the upgrade image carries binaries for the four preceding versions. A clone outside that range is refused; upgrading it means pointing pgUpgradeImage at a different major.
    • Only majors DBLab ships a default configuration for can be targeted (10–18 today).
    • The image tag keeps its extension bundle and glibc suffix; only the major changes (…:16-0.8.0-glibc236 → …:17-0.8.0-glibc236). Changing the glibc build across an upgrade would change collation behaviour, and pg_upgrade does not reindex. Pass --docker-image to override the choice; when its tag names a major, that major has to be the one being upgraded to.
    • pg_upgrade verifies that every extension in the source database has a matching library for the new major. An extension outside the image's set fails this check, and the clone rolls back untouched.
    • Clones using non-default tablespaces are refused: those live outside the clone dataset.
    • In physical mode the sync instance and the pool are untouched — the upgrade only ever acts on a clone's own dataset. The instance-wide dockerImage must still match the source major.
    • Iteration 1 limitation: a snapshot created from an upgraded clone does not record its major version, so clones created from that snapshot start on the instance-wide image and will fail to start. Avoid snapshotting upgraded clones until snapshot-level version resolution lands.

    How to contribute

    Support us on GitHub/GitLab

    The simplest way to show your support is by giving us a star on GitHub or GitLab! ⭐

    Add a star

    Spread the word

    • Tweet about DBLab and mention @Database_Lab.
    • Share a link to this repository on your favorite social media platform.

    Share your experience

    If DBLab has been a vital tool for you, tell the world about your journey. Use the logo from the ./assets folder for a visual touch. Whether it's in documents, presentations, applications, or on your website, let everyone know you trust and use DBLab.

    HTML snippet for lighter backgrounds:

    <a href="http://databaselab.io">
      <img width="400" src="https://postgres.ai/assets/powered-by-dle-for-light-background.svg" />
    </a>
    

    For darker backgrounds:

    <a href="http://databaselab.io">
      <img width="400" src="https://postgres.ai/assets/powered-by-dle-for-dark-background.svg" />
    </a>
    

    Propose an idea or report a bug

    For proposals, bug reports, and participation in development, see our Contributing Guide.

    Reference guides

    How-to guides

    You can find more in the "How-to guides" section of the documentation.

    Miscellaneous

    License

    The DBLab source code is licensed under the OSI-approved open source license Apache 2.0.

    Reach out to the PostgresAI team if you want a trial or commercial license that does not contain the GPL clauses: Contact page.

    Community & Support

    Contributor Covenant

    Many thanks to our amazing contributors!

    Translations

    Making DBLab more accessible to engineers around the globe is a great help for the project. Check details in the translation section of contributing guide.

    This README is available in the following translations:

    👉 How to make a translation contribution