Databricks Lakebase Safekeeper, Pageserver, and LTAP Architecture
Purpose
This guide explains how Databricks Lakebase separates PostgreSQL compute from durable storage, how Safekeepers and Pageservers participate in write and read paths, how log sequence numbers support versioned page reconstruction and branching, and how Lakebase connects transactional data to lakehouse analytics.
The implementation exercises use Databricks Free Edition as a perpetual, no-cost, serverless-only learning environment. Free Edition is appropriate for learning PostgreSQL behavior, Lakebase concepts, synthetic transaction workloads, branches, Unity Catalog tables, and analytical queries. It is not a production database service-level environment.
Important technical corrections
Lakebase does not simply write PostgreSQL .tar data chunks to local compute disks. Its PostgreSQL compute layer is stateless with respect to durable database storage. Durable state is maintained by a distributed storage layer made up of Safekeepers, Pageservers, and cloud object storage.
Safekeepers replicate and persist PostgreSQL write-ahead log records before a transaction commit is acknowledged. Databricks documents quorum-based WAL replication across availability zones. The internal consensus and replication implementation should be described using the official term “quorum replication” unless a specific Databricks source explicitly identifies a Paxos or Raft implementation.
Pageservers ingest WAL, maintain versioned page history, reconstruct PostgreSQL pages at a requested log sequence number, and use cloud object storage as the durable storage foundation. Pageservers are not the same as an application-visible Delta Lake or Apache Iceberg table.
Lakebase LTAP can expose transactional changes to the lakehouse through managed capabilities such as Lakebase Change Data Feed. This is different from claiming that every PostgreSQL INSERT is synchronously converted into a Delta or Iceberg Parquet file before commit.
Operational and analytical workloads can use a unified storage and governance architecture, but “zero pipeline” does not mean zero processing, zero latency, or literal zero data movement. Managed services still capture changes, materialize analytical formats, track freshness, and handle schema evolution.
Absolute point-in-time synchronization between a front-office order book and a back-office risk calculation must not be assumed. Production systems require explicit snapshot identifiers, source commit positions, LSN watermarks, event-time controls, and measured freshness.
Step 1: Create the Databricks Free Edition environment
Create a Databricks Free Edition workspace.
Use this project name:
lakebase_storage_architecture_free_nonprod
Create these workspace folders:
00_environment01_lakebase_postgres02_transaction_workload03_branching04_change_data_feed05_delta_analytics06_point_in_time_analysis07_monitoring08_governance
Create a notebook named 00_environment_check and run:
SELECT current_user() AS current_user, current_catalog() AS current_catalog, current_schema() AS current_schema, current_timestamp() AS checked_at; Document these limitations:
- Free Edition is for learning and prototyping.
- Compute is serverless-only.
- Fair-use quotas apply.
- Lakebase availability and specific LTAP capabilities can vary by cloud, region, workspace, and release state.
- No production order processing, risk enforcement, payment, or regulated books-and-records workflow should depend on the environment.
- Use synthetic data only.
Step 2: Understand traditional PostgreSQL storage
Traditional PostgreSQL combines the query process, buffer cache, WAL handling, and database data files around one host or tightly attached storage system.
Before acknowledging a commit, PostgreSQL writes the transaction's WAL record to durable storage. WAL provides a sequential recovery record and allows PostgreSQL to recover modified pages after a failure.
PostgreSQL also maintains relation data files that materialize the current state of table and index pages. A normal PostgreSQL page is commonly 8 KB.
The traditional architecture is operationally simple, but compute and storage scaling are coupled. Creating a full branch, read replica, or point-in-time copy can require substantial copying, replay, or storage provisioning.
Lakebase retains PostgreSQL transaction semantics while separating the compute and durable storage responsibilities.
Step 3: Understand the Lakebase compute layer
The Lakebase compute node runs a PostgreSQL-compatible query engine.
It performs familiar database work:
- Parse and plan SQL.
- Execute transactions.
- Maintain session state.
- Maintain an in-memory shared buffer cache.
- Generate WAL records for changes.
- Use PostgreSQL indexes and constraints.
- Return PostgreSQL protocol responses to applications.
The compute node is stateless with respect to authoritative durable database storage. It can cache pages in memory and maintain temporary local runtime state, but the durable database does not depend on one compute instance's local disk.
This separation enables:
- Scale to zero.
- Independent compute resizing.
- Faster compute restart.
- Read replicas sharing the same storage foundation.
- Instant branches using copy-on-write metadata.
- Failover without copying the full database to another compute node.
Stateless does not mean that a compute interruption is invisible to every application. Applications should use connection retry, idempotency, and transaction retry patterns appropriate to PostgreSQL.
Step 4: Understand the Safekeeper write path
When an application executes an INSERT, UPDATE, or DELETE, PostgreSQL changes pages in memory and emits WAL records describing the changes.
Instead of relying on one compute node's local WAL disk as the durable authority, the compute node streams WAL to multiple Safekeeper nodes.
A Safekeeper is a specialized WAL persistence service. It receives WAL, persists it, participates in replication, tracks LSN progress, and acknowledges durable receipt.
Lakebase acknowledges a committed transaction only after the required storage durability condition is satisfied. Databricks describes this as writing to multiple locations across availability zones and recording committed transactions durably before acknowledging them.
Use these LSN concepts:
-
insert_lsn: how far the compute WAL writer has generated WAL. -
flush_lsn: how far WAL is known to be durably persisted for the relevant path. -
commit_lsn: the WAL position associated with a committed transaction. -
replay_lsn: how far a consumer or reconstructed state has applied WAL.
Exact exposed metric names can vary. Use the documented Lakebase monitoring interfaces rather than assuming all internal LSN values are available to clients.
Do not design an application around a fixed number of Safekeepers. Databricks manages the storage topology and redundancy.
Step 5: Understand the Pageserver storage path
Pageservers receive or retrieve durable WAL and transform it into a page-version history suitable for scalable reads and long-term storage.
The storage model is log structured and non-overwriting. Historical versions are retained under the service's retention and branching model rather than updating one authoritative page file in place.
A page version is addressed by a database object and page identity together with an LSN.
A conceptual key can include:
- Relation identity.
- Fork number.
- Block number.
- Tenant or timeline identity.
A conceptual value can be:
- A complete page image.
- A WAL-derived delta that can be applied to an earlier image.
- Metadata needed to reconstruct relation state.
The internal implementation is managed by Databricks. Users should not build direct dependencies on private layer-file formats, local index structures, or undocumented storage APIs.
Step 6: Understand ingestion and layer creation
Incoming page changes and WAL-derived records are first accumulated in memory and organized for persistent storage.
When internal thresholds are reached, the storage engine creates immutable layer files.
A delta layer represents changes over a defined key and LSN range.
An image layer contains complete page images at a particular historical boundary. Image layers reduce how many deltas must be replayed for a read.
Compaction merges or reorganizes historical layers so reads do not need to traverse an unbounded sequence of small deltas.
Layer files can be uploaded to managed cloud object storage such as Amazon S3, Azure Data Lake Storage, or Google Cloud Storage, depending on the Databricks cloud.
Cloud object storage is the durable foundation. Pageservers provide the indexed and cached serving layer used by compute.
The thresholds, compaction schedules, index structures, and file sizes are service internals. Do not hard-code an assumption such as “every 1 GB creates one layer” into an institutional design unless the current Databricks documentation provides that contract.
Step 7: Understand GetPage at LSN reconstruction
When a required page is not present in the compute node's buffer cache, the compute layer requests the page from storage for a specific LSN.
Conceptually, the request is:
GetPage(page_key, requested_lsn)
The Pageserver finds the newest image layer at or before the requested LSN.
It then locates the relevant delta records after the image LSN and no later than the requested LSN.
The Pageserver replays those changes in order and reconstructs a standard PostgreSQL page.
The reconstructed page is returned to the compute node and can be cached in the PostgreSQL buffer cache.
This model supports historical page versions and branch timelines without maintaining a full physical copy for every compute or branch.
Do not promise that every page reconstruction completes in a fixed number of milliseconds. Latency depends on cache state, layer lookup, delta depth, object-storage access, network conditions, page history, and service load.
Step 8: Understand branch creation
Lakebase branches use copy-on-write storage metadata.
A new branch references an existing parent timeline at a selected point. The branch initially shares the parent's historical storage rather than copying every database page.
New writes create a separate branch history.
This makes branches useful for:
- Application development.
- Schema migration testing.
- Reproducing an incident at an earlier database state.
- Testing a new pricing or risk calculation.
- Validating a data correction before applying it to a production branch.
A branch is not a Git repository. “Git-style branching” is an analogy for fast, isolated, copy-on-write histories. Database branches do not automatically provide text merges, semantic conflict resolution, or an unrestricted merge-to-production operation.
Step 9: Create a Lakebase project
Open the Databricks app switcher and select Lakebase Postgres.
If Lakebase is not available, continue with the conceptual and Delta exercises and repeat this step in a supported workspace.
Create a project named:
storage-architecture-lab
Create a database named:
institutional_ops
Open the Lakebase SQL editor.
Create an operational schema:
CREATE SCHEMA IF NOT EXISTS trading_ops; Create a synthetic order table:
CREATE TABLE IF NOT EXISTS trading_ops.orders ( order_id UUID PRIMARY KEY, strategy_id TEXT NOT NULL, instrument_id TEXT NOT NULL, side TEXT NOT NULL CHECK (side IN ('BUY', 'SELL')), quantity NUMERIC(24,8) NOT NULL CHECK (quantity > 0), limit_price NUMERIC(24,10), order_status TEXT NOT NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), synthetic_only BOOLEAN NOT NULL DEFAULT TRUE ); Create a synthetic risk-decision table:
CREATE TABLE IF NOT EXISTS trading_ops.risk_decisions ( decision_id UUID PRIMARY KEY, order_id UUID REFERENCES trading_ops.orders(order_id), decision TEXT NOT NULL, decision_reason TEXT NOT NULL, decided_by TEXT NOT NULL, decided_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), synthetic_only BOOLEAN NOT NULL DEFAULT TRUE ); Step 10: Run a transactional write exercise
Begin a PostgreSQL transaction:
BEGIN; INSERT INTO trading_ops.orders ( order_id, strategy_id, instrument_id, side, quantity, limit_price, order_status ) VALUES ( gen_random_uuid(), 'SIM_CREDIT_RELATIVE_VALUE', 'SIM_BOND_ID_001', 'BUY', 1000000, 98.7500000000, 'PENDING_RISK' ) RETURNING order_id; Use the returned order ID to create a linked risk decision:
INSERT INTO trading_ops.risk_decisions ( decision_id, order_id, decision, decision_reason, decided_by ) VALUES ( gen_random_uuid(), '<RETURNED_ORDER_ID>'::uuid, 'APPROVED_FOR_SIMULATION', 'Synthetic limit and liquidity checks passed', 'synthetic-risk-engine' ); UPDATE trading_ops.orders SET order_status = 'APPROVED_FOR_SIMULATION', updated_at = NOW() WHERE order_id = '<RETURNED_ORDER_ID>'::uuid; COMMIT; The order, decision, and status update commit atomically. Either all become durable or the transaction rolls back.
The storage service's WAL durability path is internal. The application receives normal PostgreSQL transaction semantics.
Step 11: Verify rollback behavior
Start another transaction:
BEGIN; UPDATE trading_ops.orders SET quantity = -100 WHERE order_id = '<RETURNED_ORDER_ID>'::uuid; The check constraint should reject the invalid value.
Run:
ROLLBACK; Confirm that the valid quantity remains unchanged:
SELECT order_id, quantity, order_status FROM trading_ops.orders WHERE order_id = '<RETURNED_ORDER_ID>'::uuid; This confirms application-visible ACID behavior. It does not expose the private Safekeeper or Pageserver internals.
Step 12: Create an instant development branch
In the Lakebase interface, create a branch named:
risk-model-v2-test
Create it from the current production or main branch at the current point in time.
Connect to the new branch.
Add a test column:
ALTER TABLE trading_ops.risk_decisions ADD COLUMN model_version TEXT; Update only the branch:
UPDATE trading_ops.risk_decisions SET model_version = 'risk-model-v2-test'; Verify that the parent branch does not contain this schema change.
This exercise demonstrates storage sharing and branch isolation. It does not require a full database copy before the branch becomes available.
Step 13: Test a historical branch
Choose a timestamp before the latest synthetic order update.
Create a branch from that historical point if the current workspace and retention allow it.
Query the order from the historical branch:
SELECT order_id, order_status, updated_at FROM trading_ops.orders WHERE order_id = '<RETURNED_ORDER_ID>'::uuid; Compare the result with the current branch.
A historical branch represents the database state reachable from its selected timeline point. Its availability depends on the service's retention and restore capabilities.
Do not claim unlimited retention. Institutional retention requires an explicit policy, supported retention settings, backups or archival controls, and periodic restore tests.
Step 14: Configure Lakebase Change Data Feed
Use the Lakebase integration interface to select these PostgreSQL tables:
trading_ops.orderstrading_ops.risk_decisions
Create Unity Catalog Delta destinations such as:
lakebase_ltap_lab.raw.orders_cdflakebase_ltap_lab.raw.risk_decisions_cdf
If the catalog does not exist, create it in Databricks SQL:
CREATE CATALOG IF NOT EXISTS lakebase_ltap_lab; CREATE SCHEMA IF NOT EXISTS lakebase_ltap_lab.raw; CREATE SCHEMA IF NOT EXISTS lakebase_ltap_lab.silver; CREATE SCHEMA IF NOT EXISTS lakebase_ltap_lab.gold; Preserve or derive these fields where the integration exposes them:
- Source primary key.
- Source operation type.
- Source commit position or ordering metadata.
- Source commit time.
- Destination ingestion time.
- Branch or database identity.
The integration materializes Lakebase changes into governed Delta tables. The exact availability, naming, and setup procedure depend on the Databricks cloud and current Lakebase release.
Step 15: Measure transactional-to-analytical freshness
Create a freshness view:
CREATE OR REPLACE VIEW lakebase_ltap_lab.gold.integration_freshness AS SELECT order_id, MAX(source_commit_time) AS latest_source_commit_time, MAX(ingested_at) AS latest_delta_ingestion_time, timestampdiff( MILLISECOND, MAX(source_commit_time), MAX(ingested_at) ) AS integration_lag_ms FROM lakebase_ltap_lab.raw.orders_cdf GROUP BY order_id; Adjust the column names to match the actual generated integration table.
Measure:
- Median lag.
- 95th percentile lag.
- 99th percentile lag.
- Maximum lag.
- Number of records outside the freshness target.
Do not describe the result as zero latency.
For a learning workflow, a target such as 30 seconds can be reasonable. For front-office risk or order control, use the dedicated production control system and define a much stricter, independently validated requirement.
Step 16: Materialize analytical tables
Create a current-order analytical view from committed change records.
CREATE OR REPLACE VIEW lakebase_ltap_lab.silver.current_orders AS WITH ranked AS ( SELECT *, ROW_NUMBER() OVER ( PARTITION BY order_id ORDER BY source_commit_position DESC, ingested_at DESC ) AS row_number FROM lakebase_ltap_lab.raw.orders_cdf WHERE source_operation <> 'DELETE' ) SELECT * EXCEPT (row_number) FROM ranked WHERE row_number = 1; Replace source_commit_position and source_operation with the actual integration metadata.
Create an audit history view without collapsing versions:
CREATE OR REPLACE VIEW lakebase_ltap_lab.gold.order_history AS SELECT order_id, strategy_id, instrument_id, side, quantity, limit_price, order_status, source_operation, source_commit_position, source_commit_time, ingested_at FROM lakebase_ltap_lab.raw.orders_cdf; Use the current-state view for present analysis and the history view for investigations.
Step 17: Add Delta table optimization
Create a managed analytical table clustered for the common investigation pattern:
CREATE TABLE IF NOT EXISTS lakebase_ltap_lab.gold.orders_analytical CLUSTER BY (strategy_id, instrument_id, order_status) AS SELECT * FROM lakebase_ltap_lab.silver.current_orders; Run:
OPTIMIZE lakebase_ltap_lab.gold.orders_analytical; Liquid Clustering improves file skipping for relevant filters. It is separate from Lakebase page storage, PostgreSQL indexes, Safekeepers, and Pageserver compaction.
Do not confuse a PostgreSQL B-tree index with a Delta Lake clustering layout. Each serves a different execution engine and workload.
Step 18: Use Photon for analytical SQL
Run a risk aggregation in a serverless Databricks SQL warehouse:
SELECT strategy_id, instrument_id, order_status, COUNT(*) AS order_count, SUM(quantity) AS total_quantity, SUM(quantity * COALESCE(limit_price, 0)) AS gross_limit_notional FROM lakebase_ltap_lab.gold.orders_analytical GROUP BY strategy_id, instrument_id, order_status ORDER BY gross_limit_notional DESC; Photon accelerates compatible Databricks SQL and Spark SQL workloads on columnar lakehouse data.
Photon does not directly execute PostgreSQL row transactions and does not read private Pageserver layer files as if they were ordinary Parquet tables.
The supported path is Lakebase transactional data made available through LTAP capabilities as governed analytical data.
Step 19: Build a point-in-time risk snapshot
Create a control table for analytical watermarks:
CREATE TABLE IF NOT EXISTS lakebase_ltap_lab.gold.analysis_watermarks ( analysis_id STRING, analysis_started_at TIMESTAMP, lakebase_source_position STRING, latest_source_commit_time TIMESTAMP, latest_delta_ingestion_time TIMESTAMP, analysis_status STRING ) USING DELTA; Before a risk run, record the latest fully available source position or equivalent integration watermark.
Filter the analytical change history to records no later than that watermark.
Calculate positions, limits, or exposures from one consistent analytical cut.
Store the watermark with the result.
This allows a reviewer to answer:
- Which source changes were included?
- Which were not yet available?
- What was the measured integration lag?
- Can the result be reproduced?
This is more defensible than claiming absolute synchronization without evidence.
Step 20: Reconcile Lakebase and Delta results
Create a synthetic reconciliation process.
From Lakebase, record the count and a deterministic checksum for a bounded committed dataset.
From Delta, calculate the corresponding values at the matching integration watermark.
Compare:
- Row count.
- Distinct primary-key count.
- Insert count.
- Update count.
- Delete count.
- Sum of quantity.
- Sum of notional.
- Maximum source commit position.
Flag:
- Missing key.
- Duplicate key.
- Unexpected delete.
- Out-of-order source position.
- Schema mismatch.
- Lag outside target.
- Checksum mismatch.
Do not compare an unbounded live PostgreSQL table against a Delta table at a different point in time and label every difference an error.
Step 21: Design front-office and back-office consumers
A front-office trading application needs transactionally consistent order state, deterministic controls, and low-latency point operations. Use PostgreSQL transactions and the approved execution infrastructure.
A desk-risk application needs current position and limit data with an explicit freshness watermark. It can combine the operational change feed with market data and risk factors in Delta.
A back-office application needs complete lifecycle history, booking, allocation, settlement, and reconciliation evidence. It can use the immutable change history and independent sources.
An AI application needs governed access, data minimization, source citations, and model logging. It should not receive unrestricted order or customer details.
All consumers can use Unity Catalog governance for analytical assets. PostgreSQL permissions and Lakebase roles still require separate design for operational objects.
Step 22: Add a market-liquidity calculation
Create a synthetic market-liquidity table:
CREATE TABLE IF NOT EXISTS lakebase_ltap_lab.raw.market_depth ( observation_time TIMESTAMP, instrument_id STRING, side STRING, price DECIMAL(24,10), quantity DECIMAL(24,8), level_number INT, is_synthetic BOOLEAN ) USING DELTA; Create a current depth summary:
CREATE OR REPLACE VIEW lakebase_ltap_lab.gold.market_liquidity_summary AS SELECT instrument_id, MAX(observation_time) AS latest_observation_time, SUM(CASE WHEN side = 'BID' THEN quantity ELSE 0 END) AS bid_depth, SUM(CASE WHEN side = 'ASK' THEN quantity ELSE 0 END) AS ask_depth, ( SUM(CASE WHEN side = 'BID' THEN quantity ELSE 0 END) - SUM(CASE WHEN side = 'ASK' THEN quantity ELSE 0 END) ) / NULLIF(SUM(quantity), 0) AS depth_imbalance FROM lakebase_ltap_lab.raw.market_depth GROUP BY instrument_id; Join current simulated orders with liquidity:
SELECT o.order_id, o.strategy_id, o.instrument_id, o.side, o.quantity, l.bid_depth, l.ask_depth, l.depth_imbalance, l.latest_observation_time FROM lakebase_ltap_lab.silver.current_orders o LEFT JOIN lakebase_ltap_lab.gold.market_liquidity_summary l ON o.instrument_id = l.instrument_id; Show both the order source watermark and the market-data observation time. A synchronized database architecture does not make two external sources share the same event time.
Step 23: Apply Unity Catalog governance
Create groups:
lakebase_application_developersltap_data_engineersfront_office_analystsmiddle_office_riskback_office_operationsindependent_audit
Grant analysts access to curated views rather than raw change records unless they need the full event history.
Grant data engineers permissions to manage integration tables but not to approve trading actions.
Grant auditors read-only access to change history, analysis watermarks, lineage, and reconciliation results.
Use service principals for Lakebase integrations and scheduled analytical jobs.
Do not place PostgreSQL passwords, application tokens, or cloud credentials in notebooks.
Apply row filters and column masks to sensitive analytical data where supported.
Step 24: Monitor the storage architecture
Monitor Lakebase compute status, connection pressure, transaction errors, query latency, branch usage, storage consumption, and integration status.
Monitor the analytical path for source freshness, ingestion lag, schema drift, failed materialization, small-file growth, and query performance.
Create operational indicators:
- Lakebase connection error rate.
- Transaction retry count.
- Long-running transaction count.
- Integration median and p99 lag.
- Delta table last update time.
- Reconciliation mismatch count.
- Branch age and owner.
- Unused branch storage.
- Failed analytical job count.
Internal Safekeeper and Pageserver metrics may not all be customer exposed. Use supported Databricks monitoring surfaces and support procedures.
Step 25: Validate failure and recovery behavior
Create a synthetic transaction and commit it.
Restart or allow the compute endpoint to suspend where the service permits.
Reconnect and verify that the committed record remains available.
Create a second transaction and roll it back. Verify that the rolled-back record is absent.
Create a branch and verify that the parent and child diverge after a child write.
Generate a Lakebase update and measure when it becomes available in Delta.
Run reconciliation at a matched watermark.
Record observed recovery and integration times. Do not convert a single test into a universal SLA.
Step 26: Use the architecture for institutional-grade workloads
Use Lakebase for customer-facing or operational applications that need PostgreSQL compatibility, constraints, transactions, point reads, writes, and branches.
Use Delta or Iceberg for large historical datasets, market data, risk factors, feature engineering, surveillance histories, and large aggregations.
Use Photon through Databricks SQL for compatible analytical workloads.Source:https://dev.to/martindd/databricks-lakebase-safekeeper-pageserver-and-ltap-architecture-j8p