mirror of
https://github.com/lightningnetwork/lnd.git
synced 2026-08-16 13:00:19 +02:00
This commit implements MigrationBulkKVStore for Postgres/pgx. The Postgres wrapper is available through an explicit constructor, so regular Postgres and shared SQLite backends do not expose the migration capability accidentally. The bulk load transaction pins a dedicated *sql.Conn. InsertLeaves streams rows through pgx COPY inside that transaction. The copied row count is checked against the input to catch partial loads. Bucket rows are inserted individually with RETURNING id so nested buckets can reference their parent. Verification uses a read-only repeatable-read transaction. It fetches children of a parent-id batch with a native pgx bigint-array and a single ANY($1) query. Migration transactions honor the WithTxLevelLock used by regular transactions. Loads take the write lock and verification takes the read lock. Commit and Rollback release both the lock and the dedicated connection. Rollback is idempotent and tolerates an already-closed transaction. |
||
|---|---|---|
| .. | ||
| db.go | ||
| db_conn_set.go | ||
| log.go | ||
| migration_bulk.go | ||
| migration_bulk_postgres.go | ||
| no_sql.go | ||
| readwrite_bucket.go | ||
| readwrite_cursor.go | ||
| readwrite_tx.go | ||
| schema.go | ||