diff --git a/.agents/skills/extenddb/references/first-request/01-aws-cli-config.md b/.agents/skills/extenddb/references/first-request/01-aws-cli-config.md index e280a5f53..f3cbc1d39 100644 --- a/.agents/skills/extenddb/references/first-request/01-aws-cli-config.md +++ b/.agents/skills/extenddb/references/first-request/01-aws-cli-config.md @@ -8,7 +8,7 @@ The default port is 18443 (configured via `port` in `[server]` section of `exten ## 2. Option 1: Environment variables (simplest) -Copied verbatim from `docs/getting-started.md`, "Option A: Environment variables (simplest)": +Copied verbatim from `docs/first-requests.md` (the environment variable form): ```bash export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem @@ -25,7 +25,7 @@ Notes: ## 3. Option 2: AWS config profile (persistent) -Copied verbatim from `docs/getting-started.md`, "Option B: AWS config profile". +Copied verbatim from `docs/first-requests.md` (the AWS config profile form). Add to `~/.aws/config`: diff --git a/.agents/skills/extenddb/references/first-request/02-first-crud.md b/.agents/skills/extenddb/references/first-request/02-first-crud.md index 5b913aa28..78a483d8e 100644 --- a/.agents/skills/extenddb/references/first-request/02-first-crud.md +++ b/.agents/skills/extenddb/references/first-request/02-first-crud.md @@ -11,7 +11,7 @@ Run three operations in sequence to prove the end-to-end round trip: create a ta ## 3. Step 1: create-table -From `docs/getting-started.md`: +From `docs/first-requests.md`: ```bash aws dynamodb create-table \ @@ -43,7 +43,7 @@ aws dynamodb wait table-exists --table-name MyTable ## 4. Step 2: put-item -From `docs/getting-started.md`: +From `docs/first-requests.md`: ```bash aws dynamodb put-item \ @@ -61,7 +61,7 @@ If `--return-values ALL_OLD` is passed, the response contains the previous item ## 5. Step 3: get-item -From `docs/getting-started.md`: +From `docs/first-requests.md`: ```bash aws dynamodb get-item \ diff --git a/.agents/skills/extenddb/references/postgres/02-from-scratch.md b/.agents/skills/extenddb/references/postgres/02-from-scratch.md index bd6b266f4..7f8a7416f 100644 --- a/.agents/skills/extenddb/references/postgres/02-from-scratch.md +++ b/.agents/skills/extenddb/references/postgres/02-from-scratch.md @@ -2,59 +2,31 @@ ## 1. Purpose -`docs/local-postgres-setup.md` is the authoritative from-scratch Postgres setup guide for extenddb. It was written for Amazon Linux 2 and uses the PGDG (PostgreSQL Global Development Group) repositories, with binaries at `/usr/pgsql-15/bin/` and a data directory at `$HOME/pgdata`. Users on other platforms will need to adapt it, and most users will not need it at all because Postgres is usually already installed via the system package manager or Homebrew and only needs to be started. +The PostgreSQL section of `docs/install-from-source.md` ("1. Install and start the database" > "PostgreSQL") is the from-scratch setup guide for extenddb. It covers Ubuntu and Debian, Fedora and RHEL 9 and newer, Amazon Linux 2023, Amazon Linux 2 (PostgreSQL 15 from the PGDG repository, binaries at `/usr/pgsql-15/bin/`, data directory at `$HOME/pgdata`, running as the current user) and macOS with Homebrew. Most users will not need it because Postgres is usually already installed via the system package manager or Homebrew and only needs to be started. ## 2. When to use this file -The skill points the user at `docs/local-postgres-setup.md` only when the user explicitly asks for help installing Postgres from scratch. For most users, Postgres is already installed and `references/01-readiness-checks.md` is the right starting point. Hand off to this file only after confirming the user has no Postgres install at all. +The skill points the user at that section only when the user explicitly asks for help installing Postgres from scratch. For most users, Postgres is already installed and `references/01-readiness-checks.md` is the right starting point. Hand off to this file only after confirming the user has no Postgres install at all. -## 3. Adaptation: macOS with Homebrew +## 3. Which administrator `extenddb init` connects as -On macOS, the simpler path is Homebrew: +On a system PostgreSQL (Ubuntu, Debian, Fedora, RHEL, Amazon Linux 2023) the superuser is `postgres`: pass `--pg-user postgres` to `extenddb init`. Peer authentication is enabled for local connections, so `sudo -u postgres psql` works without a password. -```bash -brew install postgresql@17 -brew services start postgresql@17 -``` +On Homebrew (macOS) and on the Amazon Linux 2 setup the superuser is the current OS user: omit `--pg-user` (it defaults to `$(whoami)`). -The Homebrew Postgres installs the superuser as the current macOS user, not `postgres`. Use `$(whoami)` for the `--pg-user` flag in `extenddb init`. Skip the `docs/local-postgres-setup.md` steps. +Confirm the server is up with `pg_isready` before running `extenddb init`. -## 4. Adaptation: Debian and Ubuntu +## 4. What the PostgreSQL section covers -The system package installs, initializes, and starts Postgres in one command: - -```bash -sudo apt install postgresql -``` - -Confirm with `pg_isready`. The superuser is `postgres`. Peer authentication is enabled for local connections, so `sudo -u postgres psql` works without a password. Skip the PGDG repo steps in `docs/local-postgres-setup.md`. - -## 5. Adaptation: Fedora and RHEL - -The system package installs but does not initialize or start: - -```bash -sudo dnf install postgresql-server -sudo postgresql-setup --initdb -sudo systemctl enable --now postgresql -``` - -The PGDG steps in `docs/local-postgres-setup.md` are optional. The system package works for the onboarding walkthrough. - -## 6. Adaptation: Amazon Linux 2 - -Follow `docs/local-postgres-setup.md` exactly. The doc was written for this platform. - -## 7. What `docs/local-postgres-setup.md` covers - -- PGDG repository setup -- PostgreSQL 14 or newer installation +- Package installation per platform, and the PGDG repository for Amazon Linux 2 - Initialization and service start -- `pg_hba.conf` adjustment for local connections -- Verification via `psql` and `pg_isready` +- The pgvector notice `init` prints when the extension is absent +- Verification via `pg_isready` + +The `pg_hba.conf` summary for the test suite's local database is in `docs/manuals/06-developer-test-guide.md` ("Local databases for the test suite"). -## 8. Do not follow the doc's user and database creation steps +## 5. Do not follow any user and database creation steps -If `docs/local-postgres-setup.md` or `docs/troubleshooting.md` contain instructions to create a `extenddb` user, a `extenddb_catalog` database, or the `extenddb` data database, skip those steps. `extenddb init` creates them. Creating them by hand can cause `extenddb init` to fail with `Database '' already exists`, which requires `extenddb destroy --config extenddb.toml --yes` to recover. +If `docs/troubleshooting.md` or any other page contains instructions to create a `extenddb` user, a `extenddb_catalog` database, or the `extenddb` data database, skip those steps. `extenddb init` creates them. Creating them by hand can cause `extenddb init` to fail with `Database '' already exists`, which requires `extenddb destroy --config extenddb.toml --yes` to recover. The `docs/troubleshooting.md` snippet under `password authentication failed for user "extenddb"` is a post-init recovery step for when the server cannot authenticate to an existing `extenddb` role, not a pre-flight setup step. Do not run it before `extenddb init`. If a user has already run it, hand off to `extenddb-troubleshooting` for the destroy-then-init recovery sequence before attempting `extenddb init`. diff --git a/.agents/skills/extenddb/references/setup/01-environment-state.md b/.agents/skills/extenddb/references/setup/01-environment-state.md index e61695b34..6581c2f4e 100644 --- a/.agents/skills/extenddb/references/setup/01-environment-state.md +++ b/.agents/skills/extenddb/references/setup/01-environment-state.md @@ -58,7 +58,7 @@ The binary is present, but `${REPO_ROOT}/extenddb.toml` is absent. The user has The binary and `extenddb.toml` are present, but `${HOME}/.extenddb/tls/cert.pem` is absent. This is a partial-init state: `extenddb init` completed far enough to create the `extenddb_catalog` and `extenddb` data databases in PostgreSQL (and almost certainly the admin user and encryption key) but did not emit the self-signed TLS cert. Warn the user that re-running `extenddb init` will abort with a "`Database '' already exists`" error because the databases are still there. `extenddb destroy --config extenddb.toml --yes` drops both databases; run it first, then re-run `extenddb init`. Load `references/setup/04-init-stage.md` for the destroy-and-reinit sequence and the one-time credential capture warning. -Alternative path: if the user saved the admin credentials from the prior init run, they may be able to regenerate only the TLS cert pair with `openssl` (per `docs/getting-started.md`) and avoid destroying the databases. `references/setup/04-init-stage.md` covers both paths. +Alternative path: if the user saved the admin credentials from the prior init run, they may be able to regenerate only the TLS cert pair with `openssl` (per `docs/install-from-source.md`) and avoid destroying the databases. `references/setup/04-init-stage.md` covers both paths. ### `iam` diff --git a/.agents/skills/extenddb/references/setup/04-init-stage.md b/.agents/skills/extenddb/references/setup/04-init-stage.md index ff4688a83..4f0422e51 100644 --- a/.agents/skills/extenddb/references/setup/04-init-stage.md +++ b/.agents/skills/extenddb/references/setup/04-init-stage.md @@ -28,7 +28,7 @@ If `extenddb status` reports a deployment, `extenddb init` will abort with: Database '' already exists. Run 'extenddb destroy --config ' first, then re-run 'extenddb init'. ``` -This abort is driven by the PostgreSQL databases, not by `extenddb.toml`. The docs are explicit: "`extenddb init` will abort if either the catalog or data database already exists" (`docs/getting-started.md`), and "`extenddb init` detected that the catalog or data database already exists in PostgreSQL" (`docs/troubleshooting.md`). +This abort is driven by the PostgreSQL databases, not by `extenddb.toml`. The docs are explicit: "`init` refuses to run when the catalog or data database already exists" (`docs/install-from-source.md`), and "`extenddb init` detected that the catalog or data database already exists in PostgreSQL" (`docs/troubleshooting.md`). To clear the blocker, drop both databases: diff --git a/.agents/skills/extenddb/references/troubleshooting/01-symptom-index.md b/.agents/skills/extenddb/references/troubleshooting/01-symptom-index.md index fd8c4d670..687e90a94 100644 --- a/.agents/skills/extenddb/references/troubleshooting/01-symptom-index.md +++ b/.agents/skills/extenddb/references/troubleshooting/01-symptom-index.md @@ -42,7 +42,7 @@ The cause and fix summaries below are paraphrased for quick scanning. The catego **Error text:** `password authentication failed for user "extenddb"` **Cause summary:** The PostgreSQL `extenddb` user does not exist or the password does not match. -**Fix summary:** Create the `extenddb` user and database with the password extenddb expects, per `docs/local-postgres-setup.md`. +**Fix summary:** Create the `extenddb` user and database with the password extenddb expects, per `docs/troubleshooting.md`. **Full entry:** `references/02-postgres-symptoms.md#password-authentication-failed` ### migration failed diff --git a/.agents/skills/extenddb/references/troubleshooting/02-postgres-symptoms.md b/.agents/skills/extenddb/references/troubleshooting/02-postgres-symptoms.md index 3707ffcf2..b7957932c 100644 --- a/.agents/skills/extenddb/references/troubleshooting/02-postgres-symptoms.md +++ b/.agents/skills/extenddb/references/troubleshooting/02-postgres-symptoms.md @@ -44,7 +44,7 @@ psql -U "$(whoami)" -d postgres -c "CREATE USER extenddb WITH PASSWORD 'extenddb psql -U "$(whoami)" -d postgres -c "CREATE DATABASE extenddb OWNER extenddb;" ``` -See `docs/local-postgres-setup.md` for full setup instructions. +See the PostgreSQL section of `docs/install-from-source.md` for the setup. **Source:** `docs/troubleshooting.md`, section "`password authentication failed for user "extenddb"`", last synced 2026-05-12. diff --git a/.agents/skills/extenddb/references/troubleshooting/03-catalog-symptoms.md b/.agents/skills/extenddb/references/troubleshooting/03-catalog-symptoms.md index 580c4678d..b71d2e668 100644 --- a/.agents/skills/extenddb/references/troubleshooting/03-catalog-symptoms.md +++ b/.agents/skills/extenddb/references/troubleshooting/03-catalog-symptoms.md @@ -36,7 +36,7 @@ Catalog not initialized. Run 'extenddb init' to set up the catalog. **Cause:** The server connected to the database but the catalog tables don't exist. The database hasn't been initialized with `extenddb init`. **Fix:** -Run `extenddb init` to create the catalog schema and data database. See `docs/getting-started.md`. +Run `extenddb init` to create the catalog schema and data database. See `docs/install-from-source.md`. **Source:** `docs/troubleshooting.md`, section "`Catalog not initialized. Run 'extenddb init' to set up the catalog.`", last synced 2026-05-12. diff --git a/AGENTS.md b/AGENTS.md index 91193089c..6fc05c0a4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -107,9 +107,9 @@ extenddb-wasm-adapter (experimental WebAssembly build; publish = false) - Rust 1.91.1+ (`rustup update`) - Storage backend (one of): - - PostgreSQL 14+ running locally (see `docs/local-postgres-setup.md`) + - PostgreSQL 14+ running locally (see `docs/install-from-source.md`) - SQLite (embedded; nothing to install) - - MongoDB 7.0+ with replica set (see `docs/local-mongodb-setup.md`) + - MongoDB 7.0+ with replica set (see `docs/install-from-source.md`) - Cassandra 4.1+ (experimental; see `docs/cassandra-setup.md`) - Python 3.10+ for tests (`python3 -m venv ~/venvs/extenddb-venv && source ~/venvs/extenddb-venv/bin/activate && pip install -r requirements.txt`) @@ -152,14 +152,17 @@ cargo clippy --all-targets -- -D warnings ./target/release/extenddb init --config extenddb.toml # MongoDB -./target/release/extenddb init --backend mongodb --config extenddb.toml +./target/release/extenddb init --backend mongodb --config extenddb.toml --overwrite # the seed file carries [storage.mongodb].connection_string # Cassandra (experimental) -./target/release/extenddb init --backend cassandra --config extenddb.toml +export EXTENDDB_CASSANDRA_PASSWORD=cassandra +./target/release/extenddb init --backend cassandra \ + --cassandra-contact-points 127.0.0.1:9042 \ + --cassandra-user cassandra --config extenddb.toml ``` This creates: -- Databases (`extenddb_catalog` and `extenddb` on PostgreSQL; `extenddb_catalog` and `extenddb_data` on MongoDB) +- Databases (`extenddb_catalog` and `extenddb` on PostgreSQL; `extenddb_catalog` and `extenddb_data` on MongoDB; on Cassandra, the `extenddb_catalog` keyspace and the default account's `extenddb_account_` keyspace) - Admin user credentials (printed to stdout — save the password!) - Self-signed TLS certificate at `~/.extenddb/tls/cert.pem` - Config file `extenddb.toml` @@ -412,7 +415,8 @@ Expression parsing lives in `crates/core/src/expression/`. This is pure sync Rus | Document | Path | Description | |----------|---------------------------------------------------|----------------------------------------| -| Getting Started | `docs/getting-started.md` | Full setup walkthrough | +| Install from source | `docs/install-from-source.md` | Database, build, init, serve, smoke test | +| First requests | `docs/first-requests.md` | AWS CLI operations against a server | | Architecture Guide | `docs/manuals/01-architecture-guide.md` | System design and crate structure | | Admin Guide | `docs/manuals/05-admin-guide.md` | Server lifecycle, configuration, IAM | | Security Model | `docs/manuals/10-security-model.md` | Threat model, auth, authz | @@ -423,8 +427,6 @@ Expression parsing lives in `crates/core/src/expression/`. This is pure sync Rus | Storage Component Design | `docs/design/04-component-storage.md` | Storage trait design | | MongoDB Design | `docs/design/13-storage-mongodb.md` | MongoDB backend architecture | | Cassandra Design (experimental) | `docs/adr/0010`–`0021` | Cassandra backend design decisions (ADRs) | -| Local PostgreSQL Setup | `docs/local-postgres-setup.md` | PostgreSQL installation and config | -| Local MongoDB Setup | `docs/local-mongodb-setup.md` | MongoDB installation and config | | Cassandra Setup | `docs/cassandra-setup.md` | Cassandra install, config, and deployment (experimental) | | Testing Design | `docs/design/09-testing.md` | Test strategy and infrastructure | | Extending Storage | `docs/manuals/12-extending-extenddb-storage.md` | Guide to implementing storage backends | diff --git a/README.md b/README.md index 161121574..7697a27be 100755 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ export AWS_SECRET_ACCESS_KEY= aws dynamodb list-tables --endpoint-url https://127.0.0.1:18443 --region us-east-1 ``` -See [Getting Started](docs/getting-started.md) for the full walkthrough, or use the platform installer scripts: +See [Install from source](docs/install-from-source.md) for the full steps, or use the platform installer scripts: ```bash scripts/install-linux.sh # Linux @@ -116,9 +116,9 @@ scripts/install-macos.sh # macOS - Rust 1.91.1+ (`rustup update`) - Python 3.10+ (for test suites and documentation) - A storage backend: - - PostgreSQL 14+ (see `docs/local-postgres-setup.md`) + - PostgreSQL 14+ (see `docs/install-from-source.md`) - SQLite (embedded) - - MongoDB 7+ (see `docs/local-mongodb-setup.md`) + - MongoDB 7+ (see `docs/install-from-source.md`) - Cassandra 4.1+ (see `docs/cassandra-setup.md`) ### Python Environment @@ -731,7 +731,8 @@ docs/ | Document | Description | |----------|-------------| -| [Getting Started](docs/getting-started.md) | Full setup walkthrough | +| [Install from source](docs/install-from-source.md) | Database, build, init, serve and smoke test on Linux and macOS | +| [First requests](docs/first-requests.md) | Tables, items, batches, transactions and streams from the AWS CLI | | [Architecture Guide](docs/manuals/01-architecture-guide.md) | System design and crate structure | | [Admin Guide](docs/manuals/05-admin-guide.md) | Server lifecycle, configuration, IAM management | | [Security Model](docs/manuals/10-security-model.md) | Threat model, authentication, authorization | diff --git a/crates/bin/README.md b/crates/bin/README.md index 56da69657..57d25f593 100644 --- a/crates/bin/README.md +++ b/crates/bin/README.md @@ -63,7 +63,7 @@ The PostgreSQL, MongoDB and Cassandra builds each need a running database: Run `extenddb init` once to create the catalog, the admin user, a TLS certificate and `extenddb.toml`. Then run `extenddb serve`, which listens with TLS on port 18443. -[Getting started](https://github.com/ExtendDB/extenddb/blob/main/docs/getting-started.md) describes each step and +[Install from source](https://github.com/ExtendDB/extenddb/blob/main/docs/install-from-source.md) describes each step and each backend's options. ## Other ways to run ExtendDB diff --git a/docker/dockerhub-overview.md b/docker/dockerhub-overview.md index c557852c9..0a20d61ec 100644 --- a/docker/dockerhub-overview.md +++ b/docker/dockerhub-overview.md @@ -16,7 +16,7 @@ For local development, the Compose stack in the repository starts PostgreSQL alo For a real deployment the image serves three explicit operations: `extenddb init` once to bootstrap the database, `extenddb migrate` when upgrading, and `extenddb serve` in steady state, which is the default command. It listens on port 18443 over TLS, keeps configuration and certificates under `/var/lib/extenddb`, runs as a non-root user, and supports a read-only root filesystem. -To learn how to configure and operate it, see [getting started](https://github.com/ExtendDB/extenddb/blob/main/docs/getting-started.md) and the [container notes](https://github.com/ExtendDB/extenddb/blob/main/docker/README.md). +To learn how to configure and operate it, see [getting started](https://github.com/ExtendDB/extenddb/blob/main/docs/start.md) and the [container notes](https://github.com/ExtendDB/extenddb/blob/main/docker/README.md). ## Tags and verification diff --git a/docs/build-docs.py b/docs/build-docs.py index 37c11b6d3..f05a4a529 100755 --- a/docs/build-docs.py +++ b/docs/build-docs.py @@ -59,34 +59,32 @@ "docs/manuals/02-design-guide.md"), (3, "usage-guide", "Usage Guide", "usage", "docs/manuals/03-usage-guide.md"), - (4, "quickstart-setup-guide", "Quick Start & Setup Guide", "getting-started", - "docs/manuals/04-quickstart-setup-guide.md"), + (4, "install-from-source", "Install from Source", "getting-started", + "docs/install-from-source.md"), (5, "admin-guide", "Admin Guide", "usage", "docs/manuals/05-admin-guide.md"), (6, "developer-test-guide", "Developer & Test Guide", "reference", "docs/manuals/06-developer-test-guide.md"), (7, "upgrade-manual", "Upgrade Manual", "usage", "docs/manuals/07-upgrade-manual.md"), - (8, "install-linux", "Linux Installation Guide", "getting-started", - "docs/manuals/08-install-linux.md"), - (9, "install-macos", "macOS Installation Guide", "getting-started", - "docs/manuals/09-install-macos.md"), + (8, "first-requests", "First Requests", "getting-started", + "docs/first-requests.md"), (10, "security-model", "Security Model", "architecture", "docs/manuals/10-security-model.md"), (11, "deployment-guide", "Deployment Guide", "architecture", "docs/manuals/11-deployment-guide.md"), (12, "extending-extenddb-storage", "Extending extenddb Storage", "architecture", "docs/manuals/12-extending-extenddb-storage.md"), - (13, "getting-started", "Getting Started", "getting-started", - "docs/getting-started.md"), + (13, "start", "Getting Started", "getting-started", + "docs/start.md"), (14, "troubleshooting", "Troubleshooting", "usage", "docs/troubleshooting.md"), (15, "differences-from-dynamodb", "Differences from DynamoDB", "reference", "docs/differences-from-dynamodb.md"), (16, "dynamodb-limits", "DynamoDB Limits", "reference", "docs/dynamodb-limits.md"), - (17, "local-postgres-setup", "Local PostgreSQL Setup", "getting-started", - "docs/local-postgres-setup.md"), + (17, "storage-backends", "Storage Backends", "reference", + "docs/storage-backends.md"), (18, "event-ticketing-demo", "Event Ticketing Platform Demo", "getting-started", "docs/manuals/13-event-ticketing-demo.md"), (19, "backup-and-restore", "Backup and Restore", "usage", diff --git a/docs/dev-image.md b/docs/dev-image.md index 483aebc12..a0ce987aa 100644 --- a/docs/dev-image.md +++ b/docs/dev-image.md @@ -17,7 +17,7 @@ SQLite, built for local development and CI. There is no external database, no init step, and no certificate to trust: ```bash -docker run -d -p 127.0.0.1:18080:18080 -v extenddb:/var/lib/extenddb \ +docker run -d --name extenddb -p 127.0.0.1:18080:18080 -v extenddb:/var/lib/extenddb \ extenddb/extenddb-dev ``` @@ -28,6 +28,8 @@ aws dynamodb list-tables \ --region us-east-1 --endpoint-url http://127.0.0.1:18080 ``` +Once `list-tables` answers, [First requests](first-requests.md) walks through tables, items, batches, transactions and streams against this container; its endpoint table has the development image row. + It is **not the production image**. For a server with TLS and PostgreSQL, start [`extenddb/extenddb-postgres` with Docker Compose](local-dev-docker-compose.md); for running on your own servers, see the [deployment guide](manuals/11-deployment-guide.md). @@ -41,7 +43,7 @@ zero-friction local use: - **A seeded, well-known credential.** The server seeds AWS's documented example key pair (`AKIAIOSFODNN7EXAMPLE` / `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY`) on every startup by default and - prints it in the logs; sign requests with it. It is recognised by secret + prints it in the logs; sign requests with it. It is recognized by secret scanners as an example credential, so committing it in test fixtures is safe. To seed one additional key pair, pass `EXTENDDB_DEV_ACCESS_KEY_ID` and `EXTENDDB_DEV_SECRET_ACCESS_KEY` to the container (the key id must start @@ -119,7 +121,7 @@ One image serves both modes; the mode is chosen at run time. container restarts and upgrades: ```bash -docker run -d -p 127.0.0.1:18080:18080 -v extenddb:/var/lib/extenddb \ +docker run -d --name extenddb -p 127.0.0.1:18080:18080 -v extenddb:/var/lib/extenddb \ extenddb/extenddb-dev ``` @@ -127,7 +129,7 @@ docker run -d -p 127.0.0.1:18080:18080 -v extenddb:/var/lib/extenddb \ container stops, useful for test suites that want a pristine database per run: ```bash -docker run -d -p 127.0.0.1:18080:18080 \ +docker run -d --name extenddb -p 127.0.0.1:18080:18080 \ -e EXTENDDB__STORAGE__SQLITE__PATH=:memory: \ extenddb/extenddb-dev ``` @@ -156,7 +158,7 @@ condition: service_healthy` work with no extra wiring. shell, no package manager, runs as uid 65532. `docker exec` into it is not possible by design. - The binary is built with the `release-slim` profile (stripped, LTO). -- Licence notices for this image's exact dependency set ship at +- License notices for this image's exact dependency set ship at `/usr/share/doc/extenddb/SOFTWARE-LICENSE-NOTICES.html` (generated by `devtools/generate-dev-license-notices`). - Signed with Sigstore cosign; verify as described on the image's Docker Hub diff --git a/docs/differences-from-dynamodb.md b/docs/differences-from-dynamodb.md index de8f97eaf..853a030fb 100755 --- a/docs/differences-from-dynamodb.md +++ b/docs/differences-from-dynamodb.md @@ -221,7 +221,7 @@ alone, with the same wording. For PartiQL this holds in `ExecuteStatement`, | Provisioned throughput | Token bucket per table/partition | Token bucket per table/partition, matching DynamoDB's burst and refill behavior | | On-demand capacity | Automatic scaling | Fixed initial burst capacity (4000 WCU / 12000 RCU), no auto-scaling | | Warm throughput | Pre-provisions partitions to the requested read and write units; raising it is a long-running operation (`Status: UPDATING` for minutes, the previous values reported meanwhile); a request above the account's table maximum is `LimitExceededException` | Stored and reported with the same shape, defaults and validation so clients that read it (the Terraform AWS provider since 6.13.0) work: the previous values are reported with `Status: UPDATING` for `control_plane_delay_seconds` after a change, then the new values `ACTIVE`; a decrease is measured against the reported values, as on the service. Nothing acts on the values: no pre-warming and no scaling at the database level. The account maximum is not known to ExtendDB and is not enforced. A provisioned table whose warm throughput was never set, or was set on one side only, reports its new units at once after a capacity change, where the service reports the old units until the table is `ACTIVE`. Switching a table to `PAY_PER_REQUEST` stores 12000 read and 4000 write units where its warm throughput is lower, and the stored values stay after a switch back to `PROVISIONED`, as on the service; the response to the switch reads the new values with `Status: UPDATING` for `control_plane_delay_seconds`, where the service answers with the previous values and `Status: ACTIVE` | -| Throttling | Always on; throttles requests that exceed provisioned/burst capacity. No setting to disable | Configurable via `throttling_enabled` runtime setting (default: `true`) | +| Throttling | Always on; throttles requests that exceed provisioned/burst capacity. No setting to disable | Configurable via `throttling_enabled` runtime setting (default: `false`) | ## Transactions @@ -276,7 +276,7 @@ ExtendDB exposes runtime settings that have no DynamoDB equivalent: |---------|---------|-------------| | `control_plane_delay_seconds` | 5 | Simulated delay for table state transitions (CREATING → ACTIVE, DELETING → removed) | | `index_propagation_delay_ms` | 10 | System-wide default propagation delay for asynchronous secondary-index maintenance (milliseconds), covering GSIs and vector indexes alike. Per-GSI overrides stored in catalog; vector indexes have no per-index override. 0 = synchronous. Accepts the pre-rename name `gsi_propagation_delay_ms` as a deprecated alias, and a catalog created before the rename keeps honouring a value stored under it. | -| `throttling_enabled` | `true` | Enable provisioned capacity throttling (token bucket per table/partition) | +| `throttling_enabled` | `false` | Enable provisioned capacity throttling (token bucket per table/partition) | | `limits.allow_multipart_table_keys` | `false` | Enable multi-part base table key extension | | `log_level` | `info` | Runtime log level (trace, debug, info, warn, error) | | `sqlx_log_level` | `warn` | Separate log level for sqlx query traces | diff --git a/docs/first-requests.md b/docs/first-requests.md new file mode 100644 index 000000000..c1545b4a6 --- /dev/null +++ b/docs/first-requests.md @@ -0,0 +1,352 @@ +--- +description: "Tables, items, batches, transactions and streams from the AWS CLI against a running ExtendDB server, whichever way you started it." +--- + +# First requests + +Every command on this page is an ordinary AWS CLI command. The one thing that changes is where it points. Where the server came from decides the endpoint, the certificate and the credentials: + +| Server started with | Endpoint | Certificate | Credentials | +|---|---|---|---| +| The [development image](dev-image.md) | `http://127.0.0.1:18080` | none (plain HTTP) | the seeded example key pair, below | +| [Docker Compose](local-dev-docker-compose.md) | `https://127.0.0.1:18443` | `/tmp/extenddb-cert.pem`, extracted on that page | the access key created on that page | +| A [build from source](install-from-source.md) | `https://127.0.0.1:18443` | `~/.extenddb/tls/cert.pem` | the access key created in the smoke test | + +The development image seeds the example key pair from the AWS documentation: + +``` +AKIAIOSFODNN7EXAMPLE +wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY +``` + +Set the endpoint once with `AWS_ENDPOINT_URL_DYNAMODB` (the AWS CLI version 2 and the current SDKs read it), or pass `--endpoint-url ` on each command. The commands below assume the variable is set. Set both region variables, so a region already set in your shell does not win. For a TLS server, `AWS_CA_BUNDLE` points at the certificate: + +```bash +export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem +export AWS_ENDPOINT_URL_DYNAMODB=https://127.0.0.1:18443 +export AWS_DEFAULT_REGION=us-east-1 +export AWS_REGION=us-east-1 +export AWS_ACCESS_KEY_ID= +export AWS_SECRET_ACCESS_KEY= +``` + +The same settings as an AWS config profile, in `~/.aws/config`; the `dynamodb_streams` entry gives the `dynamodbstreams` commands below their endpoint: + +```ini +[profile extenddb] +region = us-east-1 +ca_bundle = ~/.extenddb/tls/cert.pem +services = extenddb-services + +[services extenddb-services] +dynamodb = + endpoint_url = https://127.0.0.1:18443 +dynamodb_streams = + endpoint_url = https://127.0.0.1:18443 +``` + +and in `~/.aws/credentials`: + +```ini +[extenddb] +aws_access_key_id = +aws_secret_access_key = +``` + +Then `export AWS_PROFILE=extenddb`. The [usage guide](manuals/03-usage-guide.md#sdk-configuration) has the same configuration for the Java, Rust, JavaScript and Python SDKs. + +## Tables + +```bash +aws dynamodb create-table \ + --table-name MyTable \ + --attribute-definitions AttributeName=pk,AttributeType=S \ + --key-schema AttributeName=pk,KeyType=HASH \ + --billing-mode PAY_PER_REQUEST +``` + +The table is created in the `CREATING` state and becomes `ACTIVE` after the control-plane delay (0.25 s by default; the service takes several seconds). Wait for it before writing: + +```bash +aws dynamodb wait table-exists --table-name MyTable +``` + +```bash +aws dynamodb list-tables +aws dynamodb describe-table --table-name MyTable +``` + +## Items + +```bash +aws dynamodb put-item \ + --table-name MyTable \ + --item '{"pk": {"S": "user-1"}, "name": {"S": "Alice"}, "age": {"N": "30"}}' +``` + +```bash +aws dynamodb get-item \ + --table-name MyTable \ + --key '{"pk": {"S": "user-1"}}' +``` + +```bash +aws dynamodb update-item \ + --table-name MyTable \ + --key '{"pk": {"S": "user-1"}}' \ + --update-expression "SET age = :newage" \ + --expression-attribute-values '{":newage": {"N": "31"}}' \ + --return-values ALL_NEW +``` + +```bash +aws dynamodb delete-item \ + --table-name MyTable \ + --key '{"pk": {"S": "user-1"}}' \ + --return-values ALL_OLD +``` + +`user-1` is gone after this; the sections below work on the items the batch write creates. + +## Batches + +```bash +aws dynamodb batch-write-item \ + --request-items '{ + "MyTable": [ + { + "PutRequest": { + "Item": { + "pk": {"S": "user-2"}, + "name": {"S": "Bob"} + } + } + }, + { + "PutRequest": { + "Item": { + "pk": {"S": "user-3"}, + "name": {"S": "Carol"} + } + } + } + ] + }' +``` + +```bash +aws dynamodb batch-get-item \ + --request-items '{ + "MyTable": { + "Keys": [ + {"pk": {"S": "user-2"}}, + {"pk": {"S": "user-3"}} + ] + } + }' +``` + +## Query and scan + +```bash +aws dynamodb query \ + --table-name MyTable \ + --key-condition-expression "pk = :pk" \ + --expression-attribute-values '{":pk": {"S": "user-2"}}' +``` + +```bash +aws dynamodb scan --table-name MyTable +``` + +## Transactions + +```bash +aws dynamodb transact-write-items \ + --transact-items '[ + { + "Put": { + "TableName": "MyTable", + "Item": { + "pk": {"S": "tx-1"}, + "data": {"S": "hello"} + } + } + }, + { + "ConditionCheck": { + "TableName": "MyTable", + "Key": {"pk": {"S": "user-2"}}, + "ConditionExpression": + "attribute_exists(pk)" + } + } + ]' +``` + +```bash +aws dynamodb transact-get-items \ + --transact-items '[ + { + "Get": { + "TableName": "MyTable", + "Key": {"pk": {"S": "tx-1"}} + } + }, + { + "Get": { + "TableName": "MyTable", + "Key": {"pk": {"S": "user-2"}} + } + } + ]' +``` + +## DynamoDB Streams + +Enable a stream when creating a table: + +```bash +aws dynamodb create-table \ + --table-name StreamTable \ + --attribute-definitions AttributeName=pk,AttributeType=S \ + --key-schema AttributeName=pk,KeyType=HASH \ + --billing-mode PAY_PER_REQUEST \ + --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES +``` + +**SDK users need a separate `dynamodbstreams` client.** In every AWS SDK, DynamoDB and DynamoDB Streams are separate services. Both clients point at the same ExtendDB endpoint URL. The Python examples on this page use boto3 (`python3 -m pip install boto3`) and read the endpoint from the variable set above; boto3 reads `AWS_CA_BUNDLE` and the key pair from the environment: + +```python +import os +import boto3 + +endpoint = os.environ["AWS_ENDPOINT_URL_DYNAMODB"] + +# DynamoDB client, for table and item operations +dynamodb = boto3.client("dynamodb", endpoint_url=endpoint) + +# DynamoDB Streams client, for stream operations +streams = boto3.client("dynamodbstreams", endpoint_url=endpoint) +``` + +On the CLI, `AWS_ENDPOINT_URL_DYNAMODB` does not apply to the `dynamodbstreams` service, so pass the endpoint explicitly (or set `AWS_ENDPOINT_URL_DYNAMODB_STREAMS`): + +```bash +aws dynamodbstreams list-streams \ + --endpoint-url "$AWS_ENDPOINT_URL_DYNAMODB" +``` + +Describe a stream (use the `LatestStreamArn` from `DescribeTable`; the label after `stream/` is the creation time with milliseconds): + +```bash +aws dynamodbstreams describe-stream \ + --endpoint-url "$AWS_ENDPOINT_URL_DYNAMODB" \ + --stream-arn \ + "arn:aws:dynamodb:us-east-1::table/StreamTable/stream/2026-04-08T07:00:00.000" +``` + +Get a shard iterator and read records: + +```bash +# Get an iterator for a shard (use a ShardId from DescribeStream) +aws dynamodbstreams get-shard-iterator \ + --endpoint-url "$AWS_ENDPOINT_URL_DYNAMODB" \ + --stream-arn \ + "arn:aws:dynamodb:us-east-1::table/StreamTable/stream/2026-04-08T07:00:00.000" \ + --shard-id "" \ + --shard-iterator-type TRIM_HORIZON + +# Read records with the iterator +aws dynamodbstreams get-records \ + --endpoint-url "$AWS_ENDPOINT_URL_DYNAMODB" \ + --shard-iterator "" +``` + +### Polling pattern + +The usual way to consume a stream is a polling loop: + +```python +import os +import time +import boto3 + +endpoint = os.environ["AWS_ENDPOINT_URL_DYNAMODB"] +streams = boto3.client("dynamodbstreams", endpoint_url=endpoint) +dynamodb = boto3.client("dynamodb", endpoint_url=endpoint) + +# Get the stream ARN from the table. +table = dynamodb.describe_table(TableName="StreamTable") +stream_arn = table["Table"]["LatestStreamArn"] + +# Discover shards. +desc = streams.describe_stream(StreamArn=stream_arn) +shards = desc["StreamDescription"]["Shards"] + +# Get an iterator for each shard. +iterators = {} +for shard in shards: + resp = streams.get_shard_iterator( + StreamArn=stream_arn, + ShardId=shard["ShardId"], + ShardIteratorType="TRIM_HORIZON", + ) + iterators[shard["ShardId"]] = resp["ShardIterator"] + +# Poll loop. +while True: + for shard_id, iterator in list(iterators.items()): + if not iterator: + continue + resp = streams.get_records(ShardIterator=iterator, Limit=100) + for record in resp.get("Records", []): + print(f"{record['eventName']}: {record['dynamodb']['Keys']}") + iterators[shard_id] = resp.get("NextShardIterator") + time.sleep(1) +``` + +[`samples/stream_consumer.py`](https://github.com/ExtendDB/extenddb/blob/main/samples/stream_consumer.py) is a complete example with concurrent writer and poller threads. Stream records are retained for 24 hours; a background worker removes expired records every hour. The [usage guide](manuals/03-usage-guide.md#dynamodb-streams) covers the shard iterator types and the stream view types. + +## Health check + +```bash +curl --cacert ~/.extenddb/tls/cert.pem https://127.0.0.1:18443/health +``` + +```json +{"components":{},"status":"healthy"} +``` + +For the development image the endpoint is `http://127.0.0.1:18080/health` with no certificate, and the body names its backup store: `{"components":{"backup_store":{"kind":"filesystem","status":"healthy"}},"status":"healthy"}`. + +## Delete the tables + +```bash +aws dynamodb delete-table --table-name MyTable +aws dynamodb delete-table --table-name StreamTable +``` + +## Next + +- [Using ExtendDB](manuals/03-usage-guide.md): the operations, expressions, transactions and streams, with examples in each SDK. +- [Administration](manuals/05-admin-guide.md): IAM users, groups, roles and policies, the web console, runtime settings and monitoring. +- [Sample application](https://github.com/ExtendDB/extenddb/blob/main/samples/sample_app.py): a Python program that creates `SampleUsers`, `SampleOrders` and `SampleTournamentMatches`, loads data, queries, updates, runs transactions and removes the tables. It reads the endpoint from `EXTENDDB_ENDPOINT` and the key pair from the AWS variables; against a TLS server it also needs the certificate: + + ```bash + export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem + export EXTENDDB_ENDPOINT=https://127.0.0.1:18443 # http://127.0.0.1:18080 for the development image, no certificate + python3 samples/sample_app.py + ``` +- [Event ticketing demo](manuals/13-event-ticketing-demo.md): a worked application with single-table design. + +--- + +## License + +Copyright 2026 ExtendDB contributors. Licensed under the Apache License, Version 2.0. +See [LICENSE](https://github.com/ExtendDB/extenddb/blob/main/LICENSE) for the full text. + +This software is provided "as is" without warranty of any kind. ExtendDB is an open +source project maintained by AWS. It is not Amazon DynamoDB or an AWS service. +"DynamoDB" is a trademark of Amazon.com, Inc. or its affiliates. diff --git a/docs/getting-started.md b/docs/getting-started.md old mode 100755 new mode 100644 index c14b1f601..98041cf8c --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1,1550 +1,11 @@ ---- -description: "Build ExtendDB from source, initialize a deployment, start the server and run DynamoDB commands against it, with every CLI option explained." ---- +# Getting started -# Full walkthrough from source +This page has moved. The content is now split by what you want to do: -> See [NOTICE](https://github.com/ExtendDB/extenddb/blob/main/docs/NOTICE.md) for important disclaimers. - -This guide builds ExtendDB from source, initializes a deployment, starts the server, and runs DynamoDB commands against it. It is the long route; for a server in one command see [Getting started](start.md), and for the two container images see the [development image](dev-image.md) and [Docker Compose with PostgreSQL](local-dev-docker-compose.md). - -## Platform-specific installation guides - -- [macOS (Homebrew)](manuals/09-install-macos.md): covers Homebrew PostgreSQL, macOS syslog, and `--pg-user $(whoami)` -- [Linux (Ubuntu/Debian, Amazon Linux, Fedora/RHEL)](manuals/08-install-linux.md): covers system PostgreSQL, `journalctl`, and `--pg-user postgres` - -## Installer scripts - -The fastest way to build ExtendDB from source is the platform installer script. -It checks dependencies, builds the binary, sets up a Python venv, and -generates PDF documentation: - -```bash -# Linux -scripts/install-linux.sh - -# macOS -scripts/install-macos.sh -``` - -The scripts report missing dependencies and exit; they never install -software on your behalf. After the script completes, continue from -[Step 2: Initialize the deployment](#2-initialize-the-deployment) below. - -## Quick start with Docker Compose - -If you have Docker, the repository's `docker-compose.yml` starts the published -PostgreSQL image (with `EXTENDDB_IMAGE=extenddb/extenddb-postgres:latest`; without -the variable it builds the image from source) together with a PostgreSQL container -and runs the initialization for you. See [Docker Compose with PostgreSQL](local-dev-docker-compose.md), -then apply the Docker Compose row of the table in [section 5](#5-configure-aws-cli) -and continue at [section 6](#6-try-it-out). - -## Prerequisites - -- **Storage backend** (one of): - - PostgreSQL 14+ running locally (see [Local PostgreSQL setup](local-postgres-setup.md)) - - SQLite (embedded; nothing to install) - - MongoDB 7.0+ with replica set (see [Local MongoDB setup](local-mongodb-setup.md)) - - Apache Cassandra 4.1+ running locally (CI runs the `cassandra:4.1` image; see [Cassandra setup](cassandra-setup.md) and [Storage backends](storage-backends.md)) -- Rust toolchain (1.91.1+) -- AWS CLI v2 (for testing) -- Python 3.10+ with virtual environment (see [Python Environment Setup](https://github.com/ExtendDB/extenddb/blob/main/README.md#python-environment) in the README) - -## 1. Build ExtendDB - -```bash -# PostgreSQL backend (default) -cargo build --release - -# MongoDB backend -# (backends are mutually exclusive; disable the default postgres feature) -cargo build --release --no-default-features --features mongodb - -# Cassandra backend -cargo build --release --no-default-features --features cassandra - -# SQLite backend (developer mode, see "SQLite backend (developer mode)" below) -cargo build --release --no-default-features --features sqlite -``` - -Each build produces a single-backend binary. The `postgres`, `mongodb`, -`cassandra` and `sqlite` features are mutually exclusive; a build enabling -more than one is rejected at compile time. To run two backends, build one -binary per backend. - -The binary is at `target/release/extenddb`. - -## 2. Initialize the deployment - -Run `extenddb init` to create the catalog and data databases: - -```bash -# PostgreSQL (default) -./target/release/extenddb init - -# MongoDB: init reads the connection string from an existing extenddb.toml -printf '[storage]\nbackend = "mongodb"\n\n[storage.mongodb]\nconnection_string = "mongodb://localhost:27017/?replicaSet=rs0"\n' > extenddb.toml -./target/release/extenddb init --backend mongodb --overwrite - -# Cassandra -./target/release/extenddb init --backend cassandra -``` - -This will: -- Create the `extenddb_catalog` database/keyspace (catalog metadata) -- Create the data database/keyspace (user item data) -- Generate an AES-256-GCM encryption key (for access key storage) -- Create a default account and print the account ID -- Create an `admin` user and print the credentials once -- Generate a self-signed TLS certificate at `~/.extenddb/tls/` -- Generate `extenddb.toml` - -**Important:** Save the admin credentials printed during init. They are shown once and cannot be retrieved later. These credentials are used to authenticate to the management API. - -**Re-initialization:** `extenddb init` will abort if either the catalog or data database already exists. To re-initialize, first run `extenddb destroy --config extenddb.toml --yes` to drop the existing databases, then run `extenddb init` again. On Cassandra, `init` aborts if the catalog is already initialized. If an earlier `init` stopped partway, `init` finishes it, when its `--replication-factor` and `--datacenter` match the ones the earlier `init` used. If `init` stops because its `--replication-factor` is larger than the number of nodes, an `init` with the same `--replication-factor` stops the same way. To go on, see "Keyspace replication" in [cassandra-setup.md](cassandra-setup.md). - -To use a custom catalog database name: - -```bash -./target/release/extenddb init --catalog-db my_catalog -``` - -To use a custom data database name: - -```bash -./target/release/extenddb init --data-db my_data_db -``` - -### Remote PostgreSQL / Aurora - -For remote PostgreSQL or Aurora, supply the admin password with `--pg-pass`: - -```bash -# Pass the password inline: -./target/release/extenddb init \ - --pg-host my-aurora-cluster.cluster-xxxx.us-east-1.rds.amazonaws.com \ - --pg-user postgres --pg-pass -``` - -When `--pg-pass` is omitted entirely, `extenddb init` connects without a password, relying on -PostgreSQL peer/ident authentication (works only on localhost via Unix socket). - -**Note:** When using Unix socket connections, specify the socket directory with `--pg-host` using an -absolute path (e.g., `--pg-host /var/run/postgresql`). Relative paths are not supported. - -### Custom bind address - -To bind the server to a specific address (e.g., for remote access), pass `--bind-addr` during init. The address is included as a SAN in the self-signed certificate and written to the generated config file: - -```bash -./target/release/extenddb init --bind-addr 10.0.1.5 -``` - -This generates a certificate with SANs: `localhost`, `127.0.0.1`, and `10.0.1.5`. - -### SQLite backend (developer mode) - -For local development and CI, ExtendDB can run against a SQLite backend instead -of PostgreSQL. It requires its own build (the `postgres`, `mongodb`, and -`sqlite` backends are mutually exclusive, each compiled into a single-backend -binary, see [Build ExtendDB](#1-build-extenddb) above): - -```bash -cargo build --release --no-default-features --features sqlite -``` - -Then select it at init time with `--backend sqlite`: - -```bash -./target/release/extenddb init --backend sqlite -``` - -This writes a config with a `[storage.sqlite]` section where the database -location is configured (default `extenddb.sqlite`): - -```toml -[storage.sqlite] -path = "extenddb.sqlite" # or ":memory:" for an ephemeral in-memory database -``` - -At init time the path can be chosen with `--sqlite-path`, which also writes it -into the generated config. At serve time the path comes from -`[storage.sqlite].path` in the config, or the `EXTENDDB__STORAGE__SQLITE__PATH` -environment variable, which overrides the config: - -```bash -./target/release/extenddb init --backend sqlite --sqlite-path /data/extenddb.sqlite -./target/release/extenddb serve --config extenddb.toml -# or, overriding at serve time: -EXTENDDB__STORAGE__SQLITE__PATH=/data/other.sqlite ./target/release/extenddb serve --config extenddb.toml -``` - -Use `:memory:` (in the config, the environment variable, or `init ---sqlite-path`) for an ephemeral database that is discarded on shutdown. - -### Cassandra backend - -ExtendDB can run against an Apache Cassandra cluster. The Cassandra backend is -experimental; see [Cassandra setup](cassandra-setup.md) for its current -limitations and the full walkthrough. Select it at init time with -`--backend cassandra`: - -```bash -./target/release/extenddb init \ - --backend cassandra \ - --cassandra-contact-points 127.0.0.1:9042 \ - --cassandra-user cassandra \ - --cassandra-pass cassandra -``` - -The node must run `PasswordAuthenticator`. `init` always creates its -application role with a password, so it fails against a stock node using the -default `AllowAllAuthenticator`; there is no credential-free path. Pass the -Cassandra admin credentials with `--cassandra-user` / `--cassandra-pass`; `init` -uses them to create the keyspaces and the application role. `init` writes a -`[storage.cassandra]` section to the config, with the application credentials. - -```toml -[storage.cassandra] -contact_points = ["127.0.0.1:9042"] -username = # From extenddb init args -password = # From extenddb init args -keyspace_prefix = "extenddb" -replication_factor = 1 # From --replication-factor (default 1) -datacenter = "datacenter1" # From --datacenter (default datacenter1) -max_connections = 10 -``` - -To override a default, pass the matching flag at init time: - -- `--cassandra-contact-points host1:9042,host2:9042`: one or more contact - points for a remote or multi-node cluster. -- `--cassandra-user` and `--cassandra-pass`: the admin credentials `init` uses - to create the keyspaces and the application role (required). -- `--extenddb-user` and `--extenddb-pass`: override the application role's name - and password (default `extenddb` / `extenddb-local-dev`). -- `--keyspace-prefix myapp`: a different keyspace prefix, so one cluster can - host more than one deployment. -- `--replication-factor 3` — the replication factor of the keyspaces (default - `1`, for a single node). Use 3 or more for a multi-node cluster. -- `--datacenter dc1` — the datacenter the keyspaces replicate in (default - `datacenter1`); use the name `nodetool status` prints. - -For replication strategy, datacenter topology, authentication, -authorization, and the fact that connections are unencrypted, see -[Cassandra setup](cassandra-setup.md). - -### Generating a self-signed certificate manually - -`extenddb init` auto-generates a self-signed TLS certificate at `~/.extenddb/tls/`. If you need a certificate with different SANs (e.g., binding to `0.0.0.0` and connecting via a specific hostname), generate one manually with `openssl`: - -```bash -# Create the TLS directory -mkdir -p ~/.extenddb/tls - -# Generate a certificate with custom SANs -openssl req -x509 -newkey rsa:2048 -nodes \ - -keyout ~/.extenddb/tls/key.pem \ - -out ~/.extenddb/tls/cert.pem \ - -days 3650 \ - -subj "/CN=extenddb self-signed/O=extenddb" \ - -addext "subjectAltName=DNS:localhost,IP:127.0.0.1,DNS:myhost.example.com,IP:10.0.1.5" - -# Restrict key file permissions -chmod 600 ~/.extenddb/tls/key.pem -``` - -Adjust the `-addext` SANs to match the hostnames and IP addresses clients will use to connect. Every address that appears in `endpoint_url` must be listed as a SAN, or TLS verification will fail. - -If the certificate already exists when `extenddb init` runs, it is preserved; init only generates a certificate when `~/.extenddb/tls/cert.pem` and `~/.extenddb/tls/key.pem` are both absent. To regenerate, delete the existing files first: - -```bash -rm ~/.extenddb/tls/cert.pem ~/.extenddb/tls/key.pem -./target/release/extenddb init --bind-addr 10.0.1.5 -``` - -## 3. Verify the deployment - -```bash -./target/release/extenddb verify --config extenddb.toml -``` - -You should see all checks pass: - -``` -=== extenddb verify === -Config: extenddb.toml -Catalog database: extenddb_catalog - ---- Checking catalog migrations... - OK: Current: the catalog is at migration 12 ---- Checking catalog connection... - OK: Connected to catalog. ---- Checking data database... - OK: Connected to data database 'extenddb'. ---- Enumerating tables... - Tables: 0 - Indexes: 0 - -=== HEALTHY: All checks passed === -``` - -## 4. Start the server - -ExtendDB runs as a daemon (background process) and logs to syslog. On startup it prints a two-line banner to stdout, the version, catalog version and bind address followed by the storage backend and its redacted connection string, then forks to background. It says "starting", not "listening": the socket is not accepting connections yet at that point. - -```bash -./target/release/extenddb serve --config extenddb.toml -# extenddb 1.0.0 (catalog migration 12) starting on 127.0.0.1:18443 -# storage: postgres (postgresql://extenddb:***@localhost:5432/extenddb_catalog) -``` - -Check status (includes the daemon PID): - -```bash -./target/release/extenddb status --config extenddb.toml -# extenddb is running on port 18443 (pid 12345) -``` - -Read logs: - -```bash -# Linux -journalctl -t extenddb -f # follow live -journalctl -t extenddb -n 50 # last 50 lines -journalctl -t extenddb --no-pager -o cat # plain output, no metadata - -# macOS -log stream --predicate 'processImagePath ENDSWITH "extenddb"' --level info -log show --predicate 'processImagePath ENDSWITH "extenddb"' --last 5m -``` - -Change the log level at runtime (takes effect within 30 seconds): - -```bash -./target/release/extenddb settings --config extenddb.toml set log_level debug -``` - -### sqlx Log Separation - -sqlx query traces are suppressed by default (level `warn`) so they don't flood the main log stream. The sqlx log level is independently configurable via the `sqlx_log_level` runtime setting: - -```bash -# Enable sqlx debug logging for query troubleshooting -./target/release/extenddb settings --config extenddb.toml set sqlx_log_level debug - -# Restore default (suppress most sqlx output) -./target/release/extenddb settings --config extenddb.toml set sqlx_log_level warn -``` - -When sqlx logging is enabled, messages appear in the `extenddb` syslog with `sqlx::query` as the target. Filter them: - -```bash -# Exclude sqlx messages -journalctl -t extenddb | grep -v sqlx - -# Show only sqlx messages -journalctl -t extenddb | grep sqlx -``` - -### Control Plane Delay - -By default, control plane operations (CreateTable, DeleteTable) emulate the service's asynchronous behavior: tables transition through CREATING → ACTIVE and DELETING → removed states over a configurable delay (default: 0.25 seconds). Adjust with: - -```bash -# Set to 0 for instant transitions (useful for fast test cycles) -./target/release/extenddb settings --config extenddb.toml set \ - control_plane_delay_seconds 0 - -# Set to 10 seconds for more realistic behavior -./target/release/extenddb settings --config extenddb.toml set \ - control_plane_delay_seconds 10 -``` - -### Warm Throughput - -`WarmThroughput` on `CreateTable`, `UpdateTable` and `GlobalSecondaryIndexUpdates` is stored and reported on `DescribeTable` with the shape, defaults (12000 read and 4000 write units on an on-demand table, the provisioned units on a provisioned one) and validation of Amazon DynamoDB, and `Status` reads `UPDATING` for the control plane delay after a change, then `ACTIVE`. Nothing acts on the values: there is no pre-warming and no scaling at the database level, and they have no effect on throughput, throttling or storage. - -### Credential Import - -Controls whether `extenddb manage import-access-key` is allowed (default: `false`). An import stores an access key ID and secret that the caller chooses, so only a deployment that sets this to `true` accepts imported keys. - -```bash -# Enable credential import -./target/release/extenddb settings --config extenddb.toml set \ - allow_credential_import true - -# Disable it again -./target/release/extenddb settings --config extenddb.toml set \ - allow_credential_import false -``` - -### GSI Propagation Delay - -GSI updates are applied asynchronously with a configurable delay, simulating the DynamoDB service's eventually consistent GSI behavior. The system-wide default is 10ms. Each GSI can override this with a per-index `propagation_delay_ms` stored in the catalog. - -```bash -# Set system-wide default to 0 for synchronous GSI updates (fast tests) -./target/release/extenddb settings --config extenddb.toml set \ - index_propagation_delay_ms 0 - -# Set to 50ms for more realistic eventual consistency -./target/release/extenddb settings --config extenddb.toml set \ - index_propagation_delay_ms 50 -``` - -### Throttling - -ExtendDB enforces provisioned throughput limits using a token bucket per table and partition, matching DynamoDB's burst and refill behavior. Throttling is enabled by default. - -```bash -# Disable throttling (useful for bulk loading) -./target/release/extenddb settings --config extenddb.toml set \ - throttling_enabled false - -# Re-enable throttling -./target/release/extenddb settings --config extenddb.toml set \ - throttling_enabled true -``` - -### TTL Deletion Target - -Controls the target maximum time (in seconds) between an item's TTL expiry and its actual deletion. The TTL sweeper uses an indexed scan and runs every 60 seconds. Default: 300 seconds. - -```bash -# Set to 60 seconds for faster TTL cleanup -./target/release/extenddb settings --config extenddb.toml set \ - ttl_deletion_target_seconds 60 - -# Set to 600 seconds for less aggressive cleanup -./target/release/extenddb settings --config extenddb.toml set \ - ttl_deletion_target_seconds 600 -``` - -Stop the server: - -```bash -./target/release/extenddb stop --config extenddb.toml -``` - -If `extenddb stop` is unavailable (e.g., older binary), fall back to manual process management: - -1. Find the process listening on the ExtendDB port (default 18443): - ```bash - ss -tlnp | grep :18443 - ``` -2. Kill it: - ```bash - kill - ``` - -## 5. Configure AWS CLI - -Where the server came from decides three settings. Apply the endpoint with `--endpoint-url ` on each command, or once with `export AWS_ENDPOINT_URL_DYNAMODB=`; the commands in section 6 assume the variable is set. - -| Server started with | Endpoint | Certificate | Credentials | -|---|---|---|---| -| The [development image](dev-image.md) | `http://127.0.0.1:18080` | none (plain HTTP) | `AKIAIOSFODNN7EXAMPLE` / `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY` | -| [Docker Compose](local-dev-docker-compose.md) | `https://127.0.0.1:18443` | the file extracted on that page (`/tmp/extenddb-cert.pem`) | the access key created with `docker compose exec extenddb extenddb manage ...` on that page | -| A build from source (this guide) | `https://127.0.0.1:18443` | `~/.extenddb/tls/cert.pem` | the access key created in [Post-init workflow](#post-init-workflow) | - -The rest of this section describes the build-from-source case. ExtendDB uses TLS with a self-signed certificate. To make AWS CLI and SDKs trust it, set `AWS_CA_BUNDLE` to the generated certificate: - -```bash -export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem -``` - -### Option A: Environment variables (simplest) - -```bash -export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem -export AWS_ENDPOINT_URL_DYNAMODB=https://127.0.0.1:18443 -export AWS_ACCESS_KEY_ID= -export AWS_SECRET_ACCESS_KEY= -export AWS_DEFAULT_REGION=us-east-1 -``` - -### Option B: AWS config profile - -Add to `~/.aws/config`: - -```ini -[profile extenddb] -region = us-east-1 -ca_bundle = ~/.extenddb/tls/cert.pem -services = extenddb-services - -[services extenddb-services] -dynamodb = - endpoint_url = https://127.0.0.1:18443 -``` - -Add to `~/.aws/credentials`: - -```ini -[extenddb] -aws_access_key_id = -aws_secret_access_key = -``` - -Then: `export AWS_PROFILE=extenddb` - -### Option C: Explicit `--endpoint-url` per command - -```bash -export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem -aws dynamodb list-tables --endpoint-url https://127.0.0.1:18443 -``` - -### Post-init workflow - -After `extenddb init`, create an IAM user and access key for SDK use: - -```bash -# Create an account (use the account ID printed during init, or create a new one) -./target/release/extenddb manage --user admin --password \ - create-account --account-name dev-team - -# Create an IAM user with a console password -./target/release/extenddb manage --user admin --password \ - create-user --account-id \ - --user-name alice --user-password secret - -# Attach a policy granting DynamoDB access -./target/release/extenddb manage --user admin --password \ - put-user-policy --account-id --user-name alice \ - --policy-name FullAccess \ - --policy-document '{ - "Version": "2012-10-17", - "Statement": [{ - "Effect": "Allow", - "Action": "dynamodb:*", - "Resource": "*" - }] - }' - -# Create an access key (shown once — save it) -./target/release/extenddb manage --user /alice --password secret \ - create-access-key -``` - -Then configure your SDK with the access key ID and secret access key returned by `create-access-key`. - -## 6. Try it out - -### Create a table - -```bash -aws dynamodb create-table \ - --table-name MyTable \ - --attribute-definitions AttributeName=pk,AttributeType=S \ - --key-schema AttributeName=pk,KeyType=HASH \ - --billing-mode PAY_PER_REQUEST -``` - -The table is created in the `CREATING` state and becomes `ACTIVE` after the control-plane delay (0.25 s by default; the service takes several seconds). Wait for it before writing: - -```bash -aws dynamodb wait table-exists --table-name MyTable -``` - -### List tables - -```bash -aws dynamodb list-tables -``` - -### Describe a table - -```bash -aws dynamodb describe-table --table-name MyTable -``` - -### Put an item - -```bash -aws dynamodb put-item \ - --table-name MyTable \ - --item '{"pk": {"S": "user-1"}, "name": {"S": "Alice"}, "age": {"N": "30"}}' -``` - -### Get an item - -```bash -aws dynamodb get-item \ - --table-name MyTable \ - --key '{"pk": {"S": "user-1"}}' -``` - -### Delete an item - -```bash -aws dynamodb delete-item \ - --table-name MyTable \ - --key '{"pk": {"S": "user-1"}}' \ - --return-values ALL_OLD -``` - -### Update an item - -```bash -aws dynamodb update-item \ - --table-name MyTable \ - --key '{"pk": {"S": "user-1"}}' \ - --update-expression "SET age = :newage" \ - --expression-attribute-values '{":newage": {"N": "31"}}' \ - --return-values ALL_NEW -``` - -### Query items - -```bash -aws dynamodb query \ - --table-name MyTable \ - --key-condition-expression "pk = :pk" \ - --expression-attribute-values '{":pk": {"S": "user-1"}}' -``` - -### Scan a table - -```bash -aws dynamodb scan --table-name MyTable -``` - -### Batch write items - -```bash -aws dynamodb batch-write-item \ - --request-items '{ - "MyTable": [ - { - "PutRequest": { - "Item": { - "pk": {"S": "user-2"}, - "name": {"S": "Bob"} - } - } - }, - { - "PutRequest": { - "Item": { - "pk": {"S": "user-3"}, - "name": {"S": "Carol"} - } - } - } - ] - }' -``` - -### Batch get items - -```bash -aws dynamodb batch-get-item \ - --request-items '{ - "MyTable": { - "Keys": [ - {"pk": {"S": "user-1"}}, - {"pk": {"S": "user-2"}} - ] - } - }' -``` - -### Transactional write - -```bash -aws dynamodb transact-write-items \ - --transact-items '[ - { - "Put": { - "TableName": "MyTable", - "Item": { - "pk": {"S": "tx-1"}, - "data": {"S": "hello"} - } - } - }, - { - "ConditionCheck": { - "TableName": "MyTable", - "Key": {"pk": {"S": "user-1"}}, - "ConditionExpression": - "attribute_exists(pk)" - } - } - ]' -``` - -### Transactional get - -```bash -aws dynamodb transact-get-items \ - --transact-items '[ - { - "Get": { - "TableName": "MyTable", - "Key": {"pk": {"S": "tx-1"}} - } - }, - { - "Get": { - "TableName": "MyTable", - "Key": {"pk": {"S": "user-1"}} - } - } - ]' -``` - -### DynamoDB Streams - -ExtendDB supports DynamoDB Streams for change data capture. Enable streams when creating a table: - -```bash -aws dynamodb create-table \ - --table-name StreamTable \ - --attribute-definitions AttributeName=pk,AttributeType=S \ - --key-schema AttributeName=pk,KeyType=HASH \ - --billing-mode PAY_PER_REQUEST \ - --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES -``` - -**Important: SDK users need a separate `dynamodbstreams` client.** In every AWS SDK, DynamoDB and DynamoDB Streams are separate services. Both clients must point at the same ExtendDB endpoint URL: - -```python -import boto3 - -# Trust the self-signed certificate -import os -os.environ["AWS_CA_BUNDLE"] = os.path.expanduser("~/.extenddb/tls/cert.pem") - -# DynamoDB client — for table/item operations -dynamodb = boto3.client("dynamodb", endpoint_url="https://127.0.0.1:18443") - -# DynamoDB Streams client — for stream operations -streams = boto3.client("dynamodbstreams", endpoint_url="https://127.0.0.1:18443") -``` - -List streams: - -```bash -aws dynamodbstreams list-streams \ - --endpoint-url https://127.0.0.1:18443 -``` - -Describe a stream (use the `LatestStreamArn` from `DescribeTable`): - -```bash -aws dynamodbstreams describe-stream \ - --endpoint-url https://127.0.0.1:18443 \ - --stream-arn \ - "arn:aws:dynamodb:us-east-1::table/StreamTable/stream/2026-04-08T07:00:00" -``` - -Get a shard iterator and read records: - -```bash -# Get iterator for a shard (use ShardId from DescribeStream) -aws dynamodbstreams get-shard-iterator \ - --endpoint-url https://127.0.0.1:18443 \ - --stream-arn \ - "arn:aws:dynamodb:us-east-1::table/StreamTable/stream/2026-04-08T07:00:00" \ - --shard-id "shard-0" \ - --shard-iterator-type TRIM_HORIZON - -# Read records using the iterator -aws dynamodbstreams get-records \ - --endpoint-url https://127.0.0.1:18443 \ - --shard-iterator "" -``` - -#### Streams polling pattern - -The standard pattern for consuming a DynamoDB stream is a polling loop: - -```python -import time -import boto3 - -streams = boto3.client("dynamodbstreams", endpoint_url="https://127.0.0.1:18443") -dynamodb = boto3.client("dynamodb", endpoint_url="https://127.0.0.1:18443") - -# Get stream ARN from the table. -table = dynamodb.describe_table(TableName="StreamTable") -stream_arn = table["Table"]["LatestStreamArn"] - -# Discover shards. -desc = streams.describe_stream(StreamArn=stream_arn) -shards = desc["StreamDescription"]["Shards"] - -# Get iterators for each shard. -iterators = {} -for shard in shards: - resp = streams.get_shard_iterator( - StreamArn=stream_arn, - ShardId=shard["ShardId"], - ShardIteratorType="TRIM_HORIZON", - ) - iterators[shard["ShardId"]] = resp["ShardIterator"] - -# Poll loop. -while True: - for shard_id, iterator in list(iterators.items()): - if not iterator: - continue - resp = streams.get_records(ShardIterator=iterator, Limit=100) - for record in resp.get("Records", []): - print(f"{record['eventName']}: {record['dynamodb']['Keys']}") - iterators[shard_id] = resp.get("NextShardIterator") - time.sleep(1) -``` - -See `samples/stream_consumer.py` for a complete working example with concurrent writer and poller threads. - -Stream records are retained for 24 hours. A background worker cleans up expired records every hour. - -### Health check - -```bash -curl --cacert ~/.extenddb/tls/cert.pem https://127.0.0.1:18443/health -# {"status":"healthy"} -``` - -### Delete the tables - -When you are done with `MyTable` and `StreamTable`: - -```bash -aws dynamodb delete-table --table-name MyTable -aws dynamodb delete-table --table-name StreamTable -``` - -## 7. Manage admin users and accounts - -The management API is available at `/management/*` on the running ExtendDB server. The `extenddb manage` CLI subcommand is a thin client that calls these endpoints. - -Admin commands require admin credentials (the username and password printed during `extenddb init`). IAM user self-service commands accept `account_id/user_name` as the `--user` value. - -**Note:** The `--password` flag is visible in process listings (`ps aux`) and shell history. For sensitive environments, leave out `--password` and set the `EXTENDDB_PASSWORD` environment variable instead, with `read -rs EXTENDDB_PASSWORD && export EXTENDDB_PASSWORD`, which keeps the password out of shell history. `extenddb manage` reads the password from `EXTENDDB_PASSWORD`, and it prints a warning on stderr when it gets `--password`. `--admin-password`, `--new-password`, `--user-password` and `--secret-access-key` have no environment variable. - -### List admin users - -```bash -./target/release/extenddb manage --user admin --password list-admins -``` - -### Create another admin user - -```bash -./target/release/extenddb manage --user admin --password \ - create-admin --admin-name ops --admin-password secret123 -``` - -### Change an admin password - -```bash -./target/release/extenddb manage --user admin --password \ - change-admin-password --admin-name admin --new-password newpw -``` - -### Delete an admin user - -```bash -./target/release/extenddb manage --user admin --password \ - delete-admin --admin-name ops -``` - -### Create an account - -Account IDs must be 12-digit numeric strings (matching AWS account ID format): - -```bash -./target/release/extenddb manage --user admin --password \ - create-account --account-id 123456789012 --account-name dev-team -``` - -### List accounts - -```bash -./target/release/extenddb manage --user admin --password list-accounts -``` - -### Delete an account - -Accounts with existing tables cannot be deleted. Delete all tables first. - -Deleting an account also deletes its users, groups and roles with everything they hold, so their access keys and sessions stop working and its users cannot log in. An account created later with the same ID starts empty. - -```bash -./target/release/extenddb manage --user admin --password \ - delete-account --account-id 123456789012 -``` - -### Create an IAM user - -Create an IAM user with optional console password. If `--user-password` is provided, the user can authenticate to the management API for self-service operations. - -```bash -./target/release/extenddb manage --user admin --password \ - create-user --account-id 123456789012 \ - --user-name alice --user-password secret -``` - -A default self-service policy is automatically attached, allowing the user to manage their own access keys and change their own password. - -### List IAM users - -```bash -./target/release/extenddb manage --user admin --password \ - list-users --account-id 123456789012 -``` - -### Delete an IAM user - -Deleting a user also removes its access keys, group memberships, tags, inline policies, permissions boundary and failed login attempts. A user created later with the same name starts with only the default `SelfServicePolicy`, and is not refused for the failed logins of the deleted one. - -```bash -./target/release/extenddb manage --user admin --password \ - delete-user --account-id 123456789012 --user-name alice -``` - -### Create an access key (self-service) - -IAM users create their own access keys by authenticating with `account_id/user_name:password`. When authenticating as an IAM user, `--account-id` and `--user-name` are inferred automatically. The secret key is shown once and cannot be retrieved later. - -Generated access keys carry ExtendDB-specific prefixes that distinguish them from AWS credentials: -- Long-lived keys: `AKIAEXTENDDB` + 8 random chars (20 total) -- Temporary credentials (AssumeRole): `ASIAEXTENDDB` + 8 random chars (20 total) -- Secret keys: `extenddb` + 32 random chars (40 total) - -```bash -# Self-service: account_id and user_name inferred from --user -./target/release/extenddb manage --user 123456789012/alice --password secret \ - create-access-key -``` - -Admins can also create access keys on behalf of any user: - -```bash -./target/release/extenddb manage --user admin --password \ - create-access-key --account-id 123456789012 --user-name alice -``` - -### List access keys - -```bash -./target/release/extenddb manage --user 123456789012/alice --password secret \ - list-access-keys --account-id 123456789012 --user-name alice -``` - -### Delete an access key - -```bash -./target/release/extenddb manage --user 123456789012/alice --password secret \ - delete-access-key --account-id 123456789012 \ - --user-name alice --access-key-id AKIAEXTENDDB... -``` - -### Import an existing access key - -Import AWS credentials (or any AKIA* key) into ExtendDB. This enables the "change only the endpoint URL" workflow: the same credentials work against ExtendDB and the DynamoDB service. - -The `allow_credential_import` runtime setting gates credential import (default: `false`). Enable it before the first import: - -```bash -./target/release/extenddb settings --config extenddb.toml set \ - allow_credential_import true -``` - -Both `--secret-access-key` and `--yes` are required: - -```bash -./target/release/extenddb manage --user admin --password \ - import-access-key --account-id 123456789012 --user-name alice \ - --access-key-id AKIAIOSFODNN7EXAMPLE \ - --secret-access-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \ - --yes -``` - -> **Security note:** `--secret-access-key` and `--password` are visible in `ps` output and shell history. For sensitive environments, set the password with `read -rs EXTENDDB_PASSWORD && export EXTENDDB_PASSWORD` and leave out `--password`. `--secret-access-key` has no environment variable. - -Set `allow_credential_import` back to `false` to refuse further imports. Keys already imported keep working. - -Credential import is not audit-logged. See [9. Audit logging](#9-audit-logging). - -### Change IAM user password - -```bash -./target/release/extenddb manage --user 123456789012/alice --password secret \ - change-user-password --account-id 123456789012 \ - --user-name alice --new-password newsecret -``` - -### Create an IAM group - -```bash -./target/release/extenddb manage --user admin --password \ - create-group --account-id 123456789012 --group-name developers -``` - -### Add a user to a group - -```bash -./target/release/extenddb manage --user admin --password \ - add-group-member --account-id 123456789012 \ - --group-name developers --user-name alice -``` - -### Remove a user from a group - -```bash -./target/release/extenddb manage --user admin --password \ - remove-group-member --account-id 123456789012 \ - --group-name developers --user-name alice -``` - -### List groups - -```bash -./target/release/extenddb manage --user admin --password \ - list-groups --account-id 123456789012 -``` - -### Delete a group - -Deleting a group also removes its inline policies and its memberships. A group created later with the same name starts with no policies and no members. - -```bash -./target/release/extenddb manage --user admin --password \ - delete-group --account-id 123456789012 --group-name developers -``` - -### Put a user policy - -Creates or replaces a named policy on an IAM user. The policy document must be valid JSON with `Version` and `Statement` fields. The user must exist; a policy put on a user that does not exist is refused with HTTP 404 `IAM user not found`. The same holds for group and role policies and for permissions boundaries. - -```bash -./target/release/extenddb manage --user admin --password \ - put-user-policy --account-id 123456789012 \ - --user-name alice \ - --policy-name ReadOnly \ - --policy-document '{ - "Version": "2012-10-17", - "Statement": [{ - "Effect": "Allow", - "Action": "dynamodb:GetItem", - "Resource": "*" - }] - }' -``` - -### List user policies - -```bash -./target/release/extenddb manage --user admin --password \ - list-user-policies --account-id 123456789012 --user-name alice -``` - -### Delete a user policy - -```bash -./target/release/extenddb manage --user admin --password \ - delete-user-policy --account-id 123456789012 \ - --user-name alice --policy-name ReadOnly -``` - -### Put a group policy - -```bash -./target/release/extenddb manage --user admin --password \ - put-group-policy --account-id 123456789012 \ - --group-name developers \ - --policy-name FullAccess \ - --policy-document '{ - "Version": "2012-10-17", - "Statement": [{ - "Effect": "Allow", - "Action": "dynamodb:*", - "Resource": "*" - }] - }' -``` - -### List group policies - -```bash -./target/release/extenddb manage --user admin --password \ - list-group-policies --account-id 123456789012 --group-name developers -``` - -### Delete a group policy - -```bash -./target/release/extenddb manage --user admin --password \ - delete-group-policy --account-id 123456789012 \ - --group-name developers \ - --policy-name FullAccess -``` - -### Tag an IAM user - -```bash -./target/release/extenddb manage --user admin --password \ - tag-user --account-id 123456789012 --user-name alice \ - --tags '[{"key":"Department","value":"Engineering"}]' -``` - -### List user tags - -```bash -./target/release/extenddb manage --user admin --password \ - list-user-tags --account-id 123456789012 --user-name alice -``` - -### Untag an IAM user - -```bash -./target/release/extenddb manage --user admin --password \ - untag-user --account-id 123456789012 --user-name alice --tag-keys Department -``` - -### Create an IAM role - -```bash -./target/release/extenddb manage --user admin --password \ - create-role --account-id 123456789012 --role-name data-reader \ - --trust-policy '{ - "Version": "2012-10-17", - "Statement": [{ - "Effect": "Allow", - "Principal": {"AWS": "arn:aws:iam::123456789012:user/alice"}, - "Action": "sts:AssumeRole" - }] - }' -``` - -### List roles - -```bash -./target/release/extenddb manage --user admin --password \ - list-roles --account-id 123456789012 -``` - -### Delete a role - -Deleting a role also removes its inline policies, permissions boundary, tags and sessions: credentials issued by `assume-role` stop working. A role created later with the same name starts with none of them. - -```bash -./target/release/extenddb manage --user admin --password \ - delete-role --account-id 123456789012 --role-name data-reader -``` - -### Put a role policy - -```bash -./target/release/extenddb manage --user admin --password \ - put-role-policy --account-id 123456789012 \ - --role-name data-reader \ - --policy-name ReadOnly \ - --policy-document '{ - "Version": "2012-10-17", - "Statement": [{ - "Effect": "Allow", - "Action": "dynamodb:GetItem", - "Resource": "*" - }] - }' -``` - -### List role policies - -```bash -./target/release/extenddb manage --user admin --password \ - list-role-policies --account-id 123456789012 --role-name data-reader -``` - -### Delete a role policy - -```bash -./target/release/extenddb manage --user admin --password \ - delete-role-policy --account-id 123456789012 \ - --role-name data-reader --policy-name ReadOnly -``` - -### Tag an IAM role - -```bash -./target/release/extenddb manage --user admin --password \ - tag-role --account-id 123456789012 --role-name data-reader \ - --tags '[{"key":"Team","value":"Backend"}]' -``` - -### List role tags - -```bash -./target/release/extenddb manage --user admin --password \ - list-role-tags --account-id 123456789012 --role-name data-reader -``` - -### Untag an IAM role - -```bash -./target/release/extenddb manage --user admin --password \ - untag-role --account-id 123456789012 --role-name data-reader --tag-keys Team -``` - -### Assume a role - -Generates temporary ASIA* credentials for the specified role. The trust policy must allow the caller ARN. - -```bash -./target/release/extenddb manage --user admin --password \ - assume-role --account-id 123456789012 --role-name data-reader \ - --caller-arn arn:aws:iam::123456789012:user/alice \ - --session-name test-session -``` - -With optional session tags and session policy: - -```bash -./target/release/extenddb manage --user admin --password \ - assume-role --account-id 123456789012 --role-name data-reader \ - --caller-arn arn:aws:iam::123456789012:user/alice \ - --session-name test-session \ - --session-tags '{"Project":"Alpha"}' \ - --session-policy '{ - "Version": "2012-10-17", - "Statement": [{ - "Effect": "Allow", - "Action": "dynamodb:GetItem", - "Resource": "*" - }] - }' \ - --duration-seconds 1800 -``` - -### Set a user permissions boundary - -```bash -./target/release/extenddb manage --user admin --password \ - set-user-boundary --account-id 123456789012 \ - --user-name alice \ - --policy-document '{ - "Version": "2012-10-17", - "Statement": [{ - "Effect": "Allow", - "Action": "dynamodb:*", - "Resource": "*" - }] - }' -``` - -### Get a user permissions boundary - -```bash -./target/release/extenddb manage --user admin --password \ - get-user-boundary --account-id 123456789012 --user-name alice -``` - -### Delete a user permissions boundary - -```bash -./target/release/extenddb manage --user admin --password \ - delete-user-boundary --account-id 123456789012 --user-name alice -``` - -### Set a role permissions boundary - -```bash -./target/release/extenddb manage --user admin --password \ - set-role-boundary --account-id 123456789012 \ - --role-name data-reader \ - --policy-document '{ - "Version": "2012-10-17", - "Statement": [{ - "Effect": "Allow", - "Action": "dynamodb:GetItem", - "Resource": "*" - }] - }' -``` - -### Get a role permissions boundary - -```bash -./target/release/extenddb manage --user admin --password \ - get-role-boundary --account-id 123456789012 --role-name data-reader -``` - -### Delete a role permissions boundary - -```bash -./target/release/extenddb manage --user admin --password \ - delete-role-boundary --account-id 123456789012 --role-name data-reader -``` - -### Using a custom endpoint - -By default, `extenddb manage` reads the server address from `extenddb.toml`. To target a different server: - -```bash -./target/release/extenddb manage --user admin --password \ - --endpoint 127.0.0.1:9000 list-admins -``` - -## 8. Management web console - -ExtendDB includes a built-in web console for managing accounts, users, groups, roles, and policies through a browser. The console is served at `/console/` on the same port as the DynamoDB API. - -### Accessing the console - -Navigate to `https://127.0.0.1:18443/console/` in your browser (adjust the host and port to match your `extenddb.toml` configuration). Accept the self-signed certificate warning on first visit. - -### Login - -- **Admin users:** Enter your admin username and password (the credentials printed during `extenddb init`). -- **IAM users:** Enter `account_id/user_name` as the username and your console password. - -### Features - -- **Dashboard:** Overview of accounts and admin users (admin sessions only; an IAM-user session gets a link to its own user page). -- **Account management:** Create, view, and delete accounts (admin only). -- **User management:** Create and delete IAM users, view access keys, policies, tags, and group memberships. -- **Access key management:** Create and delete access keys. The secret key is shown once at creation time. -- **Group management:** Create and delete groups, add and remove members. -- **Role management:** Create and delete roles, view trust policies. -- **Policy management:** Add and delete inline policies for users, groups, and roles. Includes a JSON editor with a default policy template. -- **Metrics dashboard:** Operation metrics for every account, with charts (admin only). - -Admin users have full access to all management operations. IAM users open their own user page, which lists their access keys, and create and delete their own access keys there. These are the access key reads and writes the management API gives an IAM user. The console has no form to change the password or import a key. Every other page under `/console/accounts`, the account list included, redirects an IAM-user session to the dashboard. - -Sessions end 8 hours after login. Click "Logout" to end a session immediately. Deleting a user or changing its password ends that user's sessions at their next request. - -## 9. Audit logging - -The server writes audit entries at WARN level to its log: syslog when it runs as a daemon, and stderr with `--foreground`. Two targets cover some management operations and the settings changes made through the management API: - -- `extenddb::audit::manage`: DeleteAdmin, user and role tag changes, and AssumeRole, both granted and refused by the role's trust policy. -- `extenddb::audit::settings`: each settings change made through the management API (`PUT /management/settings/{key}`). - -`extenddb settings set` changes the catalog without the server and prints its `extenddb::audit::settings` entry on its own standard output, so the server writes no audit entry for that change. A running server logs, under no audit target, when it applies a new `log_level`, `sqlx_log_level` or `throttling_enabled` value. - -Other management changes are not audit-logged. These include creating admin users, group membership and permissions boundary changes, password changes and credential import. Creating and deleting accounts, IAM users, groups, roles, access keys and policies are not audit-logged either. - -Audit entries are WARN events, so the server writes none of them while the log level (`logging.level`, or the `log_level` setting, which overrides it) is `error`, or while `logging.level` is `off` or a filter that turns the `extenddb::audit` targets off. - -Secrets (passwords, secret keys) are never included in audit log entries. - -View audit entries: - -```bash -# Linux -journalctl -t extenddb | grep 'extenddb::audit' - -# macOS -log show --predicate 'processImagePath ENDSWITH "extenddb"' --last 1d | grep 'extenddb::audit' - -# Docker Compose (--foreground) -docker compose logs extenddb | grep 'extenddb::audit' -``` - -## 10. External test suites - -ExtendDB supports running external test suites (e.g., Java/JUnit, Python/pytest) against a running instance. Suites are registered in `external-suites.toml` at the project root and referenced by path, never copied into the repo. - -### Running external suites - -```bash -# Start extenddb first -./target/release/extenddb serve --config extenddb.toml - -# Set GSI propagation delay to 0 for external tests. -# External suites expect synchronous GSI behavior (the service's propagation -# is usually under a millisecond). The async GSI path is tested -# separately by the extenddb-specific test_gsi_async.py suite. -./target/release/extenddb settings --config extenddb.toml set index_propagation_delay_ms 0 - -# Run all registered suites -python3 devtools/run-external-tests - -# Dry run — show what would execute without running -python3 devtools/run-external-tests --dry-run - -# Run a specific suite by name -python3 devtools/run-external-tests \ - --suite "My Test Suite" # the name field of a [[suite]] entry - -# Override the endpoint -python3 devtools/run-external-tests --endpoint http://localhost:9000 - -# Generate a JSON report -python3 devtools/run-external-tests --report results.json - -# Show full test output -python3 devtools/run-external-tests --verbose -``` - -### Registering a new suite - -Add a `[[suite]]` entry to `external-suites.toml`: - -```toml -[[suite]] -name = "My Test Suite" -path = "~/source/my-test-suite" -runner = "maven" # maven, gradle, pytest, or cargo -enabled = true - -[suite.env] -DDB_ENDPOINT = "${EXTENDDB_ENDPOINT}" -``` - -The `${EXTENDDB_ENDPOINT}` placeholder is replaced with the `--endpoint` value at runtime. - -Supported runners: `maven` (`mvn test`), `gradle` (`gradle test`), `pytest` (`python3 -m pytest`), `cargo` (`cargo test`). - -### Prerequisites - -Each runner requires its tools to be installed. The runner checks prerequisites before executing and skips suites with missing tools: - -- **maven:** `java`, `mvn` -- **gradle:** `java`, `gradle` -- **pytest:** `python3`, `pytest` -- **cargo:** `cargo` - -## 11. Check version - -```bash -./target/release/extenddb version -# extenddb 1.0.0 -# catalog migration 12 (postgres) -# commit abc1234 -# built 2026-04-17T12:00:00Z -# test-hooks disabled -``` - -The `-V` flag prints the same output: - -```bash -./target/release/extenddb -V -``` - -## 12. Tear down - -To completely remove a deployment: - -```bash -./target/release/extenddb destroy --config extenddb.toml --yes -``` - -The `--yes` flag is required to confirm destruction. Without it, the command exits with an error. - -## Performance Tuning - -### Connection pool size - -The `storage.postgres.pool_size` setting (default: 20, minimum: 10) sizes the connections used for DynamoDB data operations. It sizes **two** pools, not one: a deployment created by `extenddb init` keeps its catalog and its data in separate databases, and the engine opens a pool of `pool_size` against each. Both count against the same server-wide `max_connections`, because that limit is per cluster rather than per database. Each in-flight request that touches the database holds one connection for the duration of its transaction. Values below 10 are clamped at startup with a warning. - -The `storage.postgres.catalog_pool_size` setting controls the maximum number of concurrent connections for the management/catalog pool (authorization queries, IAM operations, console). Defaults to `pool_size` if not set, minimum: 10. With auth enabled (`provider = "builtin"`), each DynamoDB request makes concurrent authorization queries against this pool, size it to match expected concurrency. Values below 10 are clamped at startup with a warning. - -**When to increase:** If you see elevated latency under concurrent load, the pool may be saturated. Requests queue at the pool level when all connections are in use. Increase `pool_size` (and `catalog_pool_size` if auth is enabled) to allow more concurrent transactions. - -**Relationship to PostgreSQL `max_connections`:** The total connection footprint is `2 * pool_size + catalog_pool_size + [backup] max_concurrent_jobs`, plus one connection per vector index build running on the server and one while a schema migration runs. The `max_concurrent_jobs` term (default 4) is one dedicated connection per running backup or restore job, outside every pool, which holds the job's session-level advisory lock (its claim). The doubled term is the catalog pool and the data pool, both sized by `pool_size`; the third pool is the management pool sized by `catalog_pool_size`. A deployment whose catalog and data share one database is the only shape where the two `pool_size` pools collapse into one, and `extenddb init` does not produce it. Those extra sessions are opened outside both pools on purpose, for two different reasons. A build's ownership lock is session-scoped, so it needs a session that ends when the build does: a pooled connection would return to the pool still holding the lock. The migration lock is transaction-scoped, and needs a pinned connection because its explicit transaction has to retain one PostgreSQL backend until COMMIT, which is what stops a transaction-pooling proxy from letting the lock move between backends. PostgreSQL's default `max_connections` is 100, and the defaults already need 64 of it. Ensure `2 * pool_size + catalog_pool_size + max_concurrent_jobs`, plus the number of vector index builds you expect to overlap, does not exceed your PostgreSQL `max_connections` setting. - -**Example:** To support 50 concurrent data operations with auth enabled, set both pools to 50 in `extenddb.toml`. That configuration can open 154 connections (the default `max_concurrent_jobs` of 4 included), so PostgreSQL needs `max_connections` raised to at least 154 plus headroom for overlapping vector index builds. The default of 100 is not enough for it: an operator who sizes for 100 here meets `FATAL: sorry, too many clients already` at exactly the concurrency the setting was chosen to support. - -```toml -[storage.postgres] -pool_size = 50 -catalog_pool_size = 50 -``` - -### Contention characteristics - -- **Different items:** Fully concurrent up to `pool_size`. No contention. -- **Same item:** Concurrent writes to the same item serialize on PostgreSQL's row lock (`SELECT ... FOR UPDATE`). All updates succeed, but throughput for a single hot item is bounded by single-row transaction rate. -- **Reads:** GetItem and Query do not acquire row locks and proceed concurrently with writes. - -### Auth/authz caching - -Each DynamoDB request normally issues ~6 catalog queries during auth/authz (credential lookup, identity policies, group policies, permissions boundary, principal tags, resource tags) plus a 7th for the table's key schema. ExtendDB layers an in-memory stale-while-revalidate cache over each of these to eliminate the round-trip in steady state. - -Configured via `[auth.cache]`: - -```toml -[auth.cache] -enabled = true # master kill switch -ttl_seconds = 60 # hard TTL — entries older than this are full misses -soft_ttl_seconds = 30 # entries older than this serve cached AND trigger - # a background refresh (request does not block) -negative_ttl_seconds = 5 # how long "not found" results are remembered -max_entries = 10000 # maximum entries per cache -``` - -**Self-induced changes** (admin API and console mutations: `CreateAccessKey`, `PutUserPolicy`, `TagResource`, `CreateTable`, etc.) propagate instantly via write-through invalidation on the local instance. - -**Fanout invalidations** (`DeleteAccount`, `DeleteRole` session sweep, `DeleteGroup` member fanout) also take effect when the API returns. If a group change cannot list the group's members, those members' entries wait for `ttl_seconds`. - -**Off-instance changes** (multi-node deployments, or direct DB writes outside the management API) take up to `ttl_seconds` to propagate. - -Cache statistics are exposed at `/management/auth-cache-metrics` (JSON, admin-authenticated): hit / stale-hit / miss counts, refresh successes and failures, current entry counts per cache, and a `pass_through` flag per cache (distinguishes "disabled" from "cold"). - -## Troubleshooting - -See [Troubleshooting](troubleshooting.md) for common errors and fixes. - -## Sample Application - -A complete Python sample application is included at `samples/sample_app.py`. It demonstrates the full ExtendDB lifecycle: - -1. **Create tables**: simple PK, PK+SK with GSI, and multi-part GSI keys (tournament pattern) -2. **Poll for ACTIVE**: wait for all tables to reach ACTIVE status -3. **Load data**: PutItem and BatchWriteItem -4. **Query**: Query on base tables and GSIs (including multi-part GSI keys), Scan -5. **Update**: UpdateItem with update expressions and conditions -6. **Batch read**: BatchGetItem across multiple keys -7. **Transactions**: TransactWriteItems and TransactGetItems across tables -8. **Delete**: DeleteItem to remove individual items -9. **Drop tables**: DeleteTable to tear down all tables - -### Running the sample application - -```bash -# Start extenddb -./target/release/extenddb serve --config extenddb.toml - -# Create an IAM user with DynamoDB access (use account ID from init) -./target/release/extenddb manage --user admin --password '' \ - create-user --account-id \ - --user-name sampleuser --user-password 'SamplePass1!' - -./target/release/extenddb manage --user admin --password '' \ - put-user-policy --account-id \ - --user-name sampleuser --policy-name FullAccess \ - --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"dynamodb:*","Resource":"*"}]}' - -# Create an access key (self-service) -./target/release/extenddb manage --user /sampleuser --password 'SamplePass1!' \ - create-access-key - -# Run the sample with the access key from create-access-key output -export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem -export EXTENDDB_ENDPOINT=https://127.0.0.1:18443 -export AWS_ACCESS_KEY_ID= -export AWS_SECRET_ACCESS_KEY= -python3 samples/sample_app.py -``` - -The sample creates three tables (`SampleUsers`, `SampleOrders`, `SampleTournamentMatches`), exercises all major DynamoDB operations, and cleans up after itself. - ---- - -## License - -Copyright 2026 ExtendDB contributors. Licensed under the Apache License, Version 2.0. -See [LICENSE](https://github.com/ExtendDB/extenddb/blob/main/LICENSE) for the full text. - -This software is provided "as is" without warranty of any kind. ExtendDB is an open -source project maintained by AWS. It is not Amazon DynamoDB or an AWS service. -"DynamoDB" is a trademark of Amazon.com, Inc. or its affiliates. +- [Getting started](start.md): a server in one command with the development image, and the first requests against it. +- [Install from source](install-from-source.md): installing a database, building, `extenddb init`, `extenddb serve` and the smoke test, on Linux or macOS, for every backend. +- [Docker Compose with PostgreSQL](local-dev-docker-compose.md): the published extenddb/extenddb-postgres image with TLS. +- [First requests](first-requests.md): tables, items, batches, transactions and streams from the AWS CLI. +- [Administration](manuals/05-admin-guide.md): the `extenddb manage` command reference, the web console, runtime settings and monitoring. +- [Deployment](manuals/11-deployment-guide.md): connection pool sizing and performance tuning. +- [Developer and test guide](manuals/06-developer-test-guide.md): external test suites and local databases for the test suite. diff --git a/docs/install-from-source.md b/docs/install-from-source.md new file mode 100644 index 000000000..eb9b86a3d --- /dev/null +++ b/docs/install-from-source.md @@ -0,0 +1,611 @@ +--- +description: "Build ExtendDB from source on Linux or macOS, start a database, initialize a deployment and run the server, with the steps for every backend." +--- + +# Install from source + +A build from source gives you one binary for one storage backend. This page covers the whole path: installing the database, building, `extenddb init`, `extenddb serve`, and the smoke test. For a server in one command without a build, see [Getting started](start.md) (the development image) or [Docker Compose with PostgreSQL](local-dev-docker-compose.md). + +## Prerequisites + +- Rust 1.91.1 or newer (`rustup update`) +- A storage backend, one of: PostgreSQL 14 or newer, MongoDB 7.0 or newer running as a replica set, Apache Cassandra 4.1 or newer (see [Cassandra setup](cassandra-setup.md)), or SQLite, which needs nothing installed +- AWS CLI version 2, for the smoke test and the first requests +- Python 3.10 or newer, if you use the installer scripts (they create a virtual environment for the documentation build) + +## Installer scripts + +The repository ships one installer script per platform. Each needs the PostgreSQL client (`psql`), checks the other dependencies, builds the PostgreSQL binary, sets up a Python virtual environment for the documentation build, and renders the PDF documentation. The scripts report missing software and exit; they never install anything. + +```bash +# Linux +scripts/install-linux.sh + +# macOS +scripts/install-macos.sh +``` + +After a script completes, continue at [1. Install and start the database](#1-install-and-start-the-database) if PostgreSQL is not running yet, then at [3. Initialize the deployment](#3-initialize-the-deployment). For MongoDB, Cassandra or SQLite, follow steps 1 to 3 instead of the script. + +## 1. Install and start the database + +Skip this step for SQLite, or if your database is already running; continue at [2. Build ExtendDB](#2-build-extenddb). + +### Install PostgreSQL + +**Ubuntu or Debian** + +```bash +sudo apt-get update +sudo apt-get install -y postgresql postgresql-client +sudo systemctl start postgresql +sudo systemctl enable postgresql +``` + +**Fedora or RHEL 9 and newer** + +```bash +sudo dnf install -y postgresql-server postgresql +sudo postgresql-setup --initdb +sudo systemctl start postgresql +sudo systemctl enable postgresql +``` + +**Amazon Linux 2023** + +```bash +sudo dnf install -y postgresql15-server postgresql15 +sudo postgresql-setup --initdb +sudo systemctl start postgresql +sudo systemctl enable postgresql +``` + +**Amazon Linux 2**: install PostgreSQL 15 from the PGDG repository, after its two dependencies from the Amazon Linux 2 repositories, and run it as your own user with a data directory under your home: + +```bash +sudo yum install -y libzstd libicu +sudo rpm -ivh --nodeps \ + https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm +sudo yum install -y --releasever=7 \ + --disablerepo="*" --enablerepo="pgdg15" \ + postgresql15-server postgresql15 +/usr/pgsql-15/bin/initdb -D ~/pgdata --auth=trust --no-locale --encoding=UTF8 +/usr/pgsql-15/bin/pg_ctl -D ~/pgdata -l ~/pgdata/server.log start +``` + +**macOS (Homebrew)** + +```bash +brew install postgresql@17 +brew services start postgresql@17 +export PATH="$(brew --prefix postgresql@17)/bin:$PATH" +``` + +The `postgresql@17` formula is keg-only, so its binaries (`pg_isready`, `psql`) are not on `PATH` until the export above or `brew link --overwrite postgresql@17`. On Homebrew the PostgreSQL superuser is your macOS user name, not `postgres`, with trust authentication over the local socket. The same is true of the Amazon Linux 2 setup above. To run the server without `brew services`, start it on the formula's data directory: `pg_ctl -D "$(brew --prefix)/var/postgresql@17" -l "$(brew --prefix)/var/postgresql@17/server.log" start` (`brew --prefix` is `/opt/homebrew` on Apple silicon). + +Confirm the server accepts connections: + +```bash +pg_isready +``` + +``` +/var/run/postgresql:5432 - accepting connections +``` + +On macOS the socket directory shown is `/tmp`. + +Vector indexes need the pgvector extension on the data database. `init` tries to create it and prints a notice when it is not installed; the server runs without it and refuses vector indexes until it is present. + +### Install MongoDB + +ExtendDB uses multi-document transactions, so MongoDB must run as a replica set, including a single node. + +**Container** + +```bash +docker run -d --name extenddb-mongo -p 127.0.0.1:27017:27017 mongo:7 --replSet rs0 +docker exec extenddb-mongo mongosh --quiet --eval \ + 'rs.initiate({_id: "rs0", members: [{_id: 0, host: "localhost:27017"}]})' +``` + +The member is named `localhost:27017`, the address the published port answers on, so `?replicaSet=rs0` finds the primary from the host. A bare `rs.initiate()` names the member after the container ID, which the host cannot resolve. + +**Ubuntu or Debian** + +```bash +curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \ + sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor +echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] \ + https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | \ + sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list +sudo apt-get update && sudo apt-get install -y mongodb-org +``` + +Add the replica set name to `/etc/mongod.conf`, restart `mongod`, then run `mongosh --eval "rs.initiate()"`: + +```yaml +replication: + replSetName: rs0 +``` + +**macOS (Homebrew)** + +```bash +brew tap mongodb/brew +brew install mongodb-community@7.0 +``` + +Add the same `replication` block to the file that `brew --prefix mongodb-community@7.0` points at (`/opt/homebrew/etc/mongod.conf` on Apple silicon), then: + +```bash +brew services restart mongodb-community@7.0 +mongosh --eval "rs.initiate()" +``` + +Wait a few seconds for the primary election and confirm: + +```bash +mongosh --eval "rs.status().ok" +``` + +``` +1 +``` + +### Install Cassandra + +The test suite runs against the `cassandra:4.1` image with password authentication. A single node for development: + +```bash +docker run -d --name extenddb-cassandra -p 127.0.0.1:9042:9042 \ + -e CASSANDRA_CLUSTER_NAME=extenddb -e HEAP_NEWSIZE=128M -e MAX_HEAP_SIZE=1024M \ + cassandra:4.1 +``` + +Cassandra takes a minute or more to start. It is ready when this returns the version: + +```bash +docker exec extenddb-cassandra cqlsh -e 'SELECT release_version FROM system.local' +``` + +`extenddb init` creates an application role with a password, which the image's default `AllowAllAuthenticator` rejects (`CassandraRoleManager doesn't support PASSWORD`). Switch the node to `PasswordAuthenticator` and restart it; the `cassandra` superuser with password `cassandra` then exists: + +```bash +docker exec extenddb-cassandra sed -i \ + 's/^authenticator: .*/authenticator: PasswordAuthenticator/' /etc/cassandra/cassandra.yaml +docker restart extenddb-cassandra +``` + +It is ready again when this returns the version (about 15 seconds): + +```bash +docker exec extenddb-cassandra cqlsh -u cassandra -p cassandra \ + -e 'SELECT release_version FROM system.local' +``` + +## 2. Build ExtendDB + +```bash +git clone https://github.com/ExtendDB/extenddb.git +cd extenddb +``` + +```bash +# PostgreSQL (the default feature) +cargo build --release + +# MongoDB +cargo build --release --no-default-features --features mongodb + +# Cassandra +cargo build --release --no-default-features --features cassandra + +# SQLite +cargo build --release --no-default-features --features sqlite +``` + +The backend features are mutually exclusive: a build that enables more than one is rejected at compile time, and each build produces a single-backend binary at `target/release/extenddb`. To run two backends side by side, build one binary per backend. + +Check the build: + +```bash +./target/release/extenddb version +``` + +``` +extenddb 1.0.0 +catalog migration 12 (postgres) +commit ceb6a63a +built 2026-10-24T08:37:05Z +test-hooks disabled +``` + +`extenddb -V` prints the same. + +## 3. Initialize the deployment + +`extenddb init` creates the application database user, the catalog and data databases, applies the schema migrations, generates an AES-256-GCM key for access key storage, creates a default account and an `admin` user, generates a self-signed TLS certificate at `~/.extenddb/tls/`, and writes `extenddb.toml`. For PostgreSQL, Cassandra and SQLite, `init` writes the whole file: do not write one by hand first. MongoDB is the exception, below. + +`init` connects as a database administrator to create the databases. Which flags you pass depends on the backend and on who that administrator is. + +### Initialize on PostgreSQL + +On a system PostgreSQL (Ubuntu, Debian, Fedora, RHEL, Amazon Linux 2023) the administrator is `postgres`. It has no password, and the packages let it in only over the local socket as the `postgres` operating system user. Give it a password. On Fedora, RHEL and Amazon Linux 2023, also switch TCP connections from `ident` to password authentication; Ubuntu and Debian already use `scram-sha-256` for TCP. + +```bash +sudo -u postgres psql -c "ALTER ROLE postgres PASSWORD ''" + +# Fedora, RHEL and Amazon Linux 2023 only +sudo sed -i 's/^\(host .*\)ident$/\1scram-sha-256/' /var/lib/pgsql/data/pg_hba.conf +sudo systemctl reload postgresql +``` + +```bash +export EXTENDDB_PG_PASSWORD='' +./target/release/extenddb init --pg-user postgres +``` + +Where PostgreSQL runs as your own user (Homebrew on macOS, the Amazon Linux 2 setup above), omit `--pg-user`; it defaults to your user name: + +```bash +./target/release/extenddb init +``` + +For a remote server or Amazon Aurora, give the host and the administrator password. Put the password in `EXTENDDB_PG_PASSWORD` rather than on the command line: + +```bash +export EXTENDDB_PG_PASSWORD='' +./target/release/extenddb init \ + --pg-host my-cluster.cluster-xxxx.us-east-1.rds.amazonaws.com \ + --pg-user postgres +``` + +Without a password `init` connects with peer or ident authentication, which works only over a local Unix socket and only for a role named after your operating system user. To use a socket, pass the socket directory to `--pg-host` as an absolute path (`--pg-host /var/run/postgresql`). + +### Initialize on MongoDB + +The MongoDB build reads the connection string from the config file, so write a two-section `extenddb.toml` first and let `init` complete it: + +```bash +cat > extenddb.toml <<'EOF' +[storage] +backend = "mongodb" + +[storage.mongodb] +connection_string = "mongodb://localhost:27017/?replicaSet=rs0" +EOF + +./target/release/extenddb init --backend mongodb --config extenddb.toml --overwrite +``` + +`--overwrite` lets `init` replace the seed file with the full config; without it `init` exits because the file exists. The databases are `extenddb_catalog` and `extenddb_data`; the MongoDB build does not take `--data-db` or `--catalog-db`. For a container on another port use `mongodb://localhost:27018/?replicaSet=rs0&directConnection=true`. + +### Initialize on Cassandra + +The Cassandra backend is experimental; see [Cassandra setup](cassandra-setup.md) for its current limitations and the full walkthrough. + +```bash +export EXTENDDB_CASSANDRA_PASSWORD=cassandra +./target/release/extenddb init --backend cassandra \ + --cassandra-contact-points 127.0.0.1:9042 \ + --cassandra-user cassandra +``` + +The node must run `PasswordAuthenticator`. `init` always creates its application role with a password, so it fails against a stock node using the default `AllowAllAuthenticator`; there is no credential-free path. + +`init` connects as the superuser named by `--cassandra-user`, creates the `extenddb` application role, the catalog keyspace and one keyspace for the default account (further accounts get their own on demand), and writes `[storage.cassandra]` with the contact points, the application role, `keyspace_prefix = "extenddb"` and `replication_factor = 1`: + +```toml +[storage.cassandra] +contact_points = ["127.0.0.1:9042"] +username = # From extenddb init args +password = # From extenddb init args +keyspace_prefix = "extenddb" +replication_factor = 1 # From --replication-factor (default 1) +datacenter = "datacenter1" # From --datacenter (default datacenter1) +max_connections = 10 +``` + +To override a default, pass the matching flag at init time: + +- `--cassandra-contact-points host1:9042,host2:9042`: one or more contact points for a remote or multi-node cluster. +- `--cassandra-user` and `--cassandra-pass`: the superuser credentials `init` uses to create the keyspaces and the application role. The password can come from `EXTENDDB_CASSANDRA_PASSWORD` instead of the flag, as in the example above; without `--cassandra-user`, `init` connects as `$USER`, or as `cassandra` when `USER` is not set. +- `--extenddb-user` and `--extenddb-pass`: override the application role's name and password (default `extenddb` / `extenddb-local-dev`). +- `--keyspace-prefix myapp`: a different keyspace prefix, so one cluster can host more than one deployment. +- `--replication-factor 3`: the replication factor of the keyspaces (default `1`, for a single node). Use 3 or more for a multi-node cluster. +- `--datacenter dc1`: the datacenter the keyspaces replicate in (default `datacenter1`); use the name `nodetool status` prints. + +For replication strategy, datacenter topology, authentication, authorization, and the fact that connections are unencrypted, see [Cassandra setup](cassandra-setup.md). + +### Initialize on SQLite + +```bash +./target/release/extenddb init --backend sqlite --sqlite-path extenddb.sqlite +``` + +The path is written into the generated config under `[storage.sqlite].path`, so `serve` finds it without further flags. `:memory:` gives an ephemeral database that is discarded on shutdown. At serve time the environment variable `EXTENDDB__STORAGE__SQLITE__PATH` overrides the config. + +### Options + +What `init` prints, abridged (the full output also names the certificate files it generated, lists every applied migration and, when the rendered documentation is absent, says that `/console/docs` is disabled): + +``` +=== extenddb init (backend: postgres) === +--- Ensuring application user 'extenddb' exists... + Created user 'extenddb'. +--- Creating database 'extenddb_catalog'... + Created. +--- Creating database 'extenddb'... + Created. +--- Creating the catalog through its migrations... + Applied migration 1 baseline in extenddb_catalog + Applied migration 1 baseline in extenddb + ... + Applied migration 11 attribute_name_escape in extenddb + Recorded migration 12 unique_access_key_ids in extenddb_catalog as not applicable +--- Generating AES-256-GCM encryption key... + Encryption key stored. +--- Creating default account '123190565100'... + Account ID: 123190565100 +--- Creating admin user 'admin'... +--- Recording data database connection in catalog... + + Admin credentials (shown once, save them now) + Username: admin + Password: + +--- Generating extenddb.toml... + Created extenddb.toml + +=== extenddb init complete === +Start the server with: extenddb serve --config extenddb.toml +``` + +Save the admin password: it is shown once and cannot be retrieved. The PostgreSQL `init` also prints the default account's ID, the account you create IAM users in. On PostgreSQL, SQLite and Cassandra, `manage list-accounts` prints it ([6. Smoke test](#6-smoke-test)). On MongoDB the account that `init` creates is not listed, and the server refuses access keys made under it, because its document has no `account_id` field ([#643](https://github.com/ExtendDB/extenddb/issues/643)); create an account to work in and use the `account_id` it prints: + +```bash +export EXTENDDB_PASSWORD='' +./target/release/extenddb manage --user admin create-account --account-name dev +``` + +`init` refuses to run when the catalog or data database already exists. To start over, run `extenddb destroy --config extenddb.toml --yes` with the same `--pg-user` as `init` first (see [Tear down](#tear-down)). It also refuses to overwrite an existing `extenddb.toml` unless `--overwrite` is given (`Error: Config file "extenddb.toml" already exists. Use --overwrite to delete and regenerate it.`, exit 255); with `--overwrite` it loads the PostgreSQL connection defaults from the existing file and writes a new one. On Cassandra, `init` aborts if the catalog is already initialized. If an earlier `init` stopped partway, `init` finishes it, when its `--replication-factor` and `--datacenter` match the ones the earlier `init` used. If `init` stops because its `--replication-factor` is larger than the number of nodes, an `init` with the same `--replication-factor` stops the same way. To go on, see [Keyspace replication](cassandra-setup.md#keyspace-replication). + +| Flag | What it does | +|---|---| +| `--data-db ` | Data database name (default: the catalog's name without `_catalog`, `extenddb` for the default catalog); PostgreSQL | +| `--catalog-db ` | Catalog database name (default `extenddb_catalog`, or the config file's); PostgreSQL | +| `--extenddb-user ` | The application database user `init` creates (default `extenddb`); PostgreSQL and Cassandra | +| `--extenddb-pass ` | That user's password (default `extenddb-local-dev`, or `EXTENDDB_APP_PASSWORD`); PostgreSQL and Cassandra | +| `--pg-host `, `--pg-port ` | PostgreSQL host (or absolute socket directory) and port | +| `--bind-addr ` | Address the server binds to; also added to the certificate's Subject Alternative Names | +| `--tls-san ` | Another name or address for the certificate, repeatable (for example an in-cluster service name) | +| `--config ` | Where to write the config file (default `extenddb.toml`) | + +If the certificate files already exist at `~/.extenddb/tls/`, `init` keeps them. To regenerate with different names, delete `cert.pem` and `key.pem` there and run `init` again with the `--bind-addr` and `--tls-san` values the clients will use; every address in a client's endpoint URL must be a SAN or TLS verification fails. To make a certificate yourself instead: + +```bash +mkdir -p ~/.extenddb/tls +openssl req -x509 -newkey rsa:2048 -nodes \ + -keyout ~/.extenddb/tls/key.pem \ + -out ~/.extenddb/tls/cert.pem \ + -days 3650 \ + -subj "/CN=extenddb self-signed/O=extenddb" \ + -addext "subjectAltName=DNS:localhost,IP:127.0.0.1,DNS:myhost.example.com,IP:10.0.1.5" +chmod 600 ~/.extenddb/tls/key.pem +``` + +## 4. Verify the deployment + +```bash +./target/release/extenddb verify --config extenddb.toml +``` + +``` +=== extenddb verify === +Config: extenddb.toml +Catalog database: extenddb_catalog + +--- Checking catalog migrations... + OK: Current: the catalog is at migration 12 +--- Checking catalog connection... + OK: Connected to catalog. +--- Checking data database... + OK: Connected to data database 'extenddb'. +--- Enumerating tables... + Tables: 0 + Indexes: 0 + +=== HEALTHY: All checks passed === +``` + +## 5. Start the server + +```bash +./target/release/extenddb serve --config extenddb.toml +``` + +The banner follows an ASCII wordmark: + +``` +extenddb 1.0.0 (catalog migration 12) starting on 127.0.0.1:18443 + storage: postgres (postgresql://extenddb:***@localhost:5432/extenddb_catalog) + backup store: none ([backup.store] is absent); CreateBackup writes in-catalog backups +extenddb server started (pid 8644, 127.0.0.1:18443) +``` + +The server runs as a daemon and logs to syslog. The banner says "starting": the socket accepts connections a moment later. + +```bash +./target/release/extenddb status --config extenddb.toml +``` + +``` +extenddb is running on port 18443 (pid 8644) +``` + +Read the logs: + +```bash +# Linux +journalctl -t extenddb -f + +# macOS +log stream --predicate 'processImagePath ENDSWITH "extenddb"' --level info +``` + +Stop it: + +```bash +./target/release/extenddb stop --config extenddb.toml +``` + +``` +extenddb stopped (pid 8644) +``` + +[Administration](manuals/05-admin-guide.md) covers the server lifecycle, the configuration file, runtime settings and monitoring. + +## 6. Smoke test + +The health endpoint needs no credential: + +```bash +curl --cacert ~/.extenddb/tls/cert.pem https://127.0.0.1:18443/health +``` + +```json +{"components":{},"status":"healthy"} +``` + +Every DynamoDB request must be signed with an access key, so create an IAM user in the default account and give it a policy and a key. `extenddb manage` reads the server endpoint from `extenddb.toml` in the current directory; `--endpoint host:port` overrides it. Use the admin password that `init` printed. Put it in `EXTENDDB_PASSWORD`: `--password` works too, but the command then warns that the password is visible in process listings and shell history. The account ID is the `account_id` that `list-accounts` prints: + +```bash +export EXTENDDB_PASSWORD='' +./target/release/extenddb manage --user admin list-accounts +``` + +```json +[ + { + "account_id": "123190565100", + "account_name": "default", + "created_at": "2026-11-25T11:49:45.772244Z" + } +] +``` + +```bash +./target/release/extenddb manage --user admin \ + create-user --account-id \ + --user-name alice --user-password '' + +./target/release/extenddb manage --user admin \ + put-user-policy --account-id --user-name alice \ + --policy-name FullAccess \ + --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"dynamodb:*","Resource":"*"}]}' + +EXTENDDB_PASSWORD='' ./target/release/extenddb manage --user /alice \ + create-access-key +``` + +```json +{ + "access_key_id": "AKIAEXTENDDB...", + "secret_access_key": "..." +} +``` + +The secret is shown once. Point the AWS CLI at the server and list tables. Set both region variables: an `AWS_REGION` already set in your shell would otherwise win over `AWS_DEFAULT_REGION`, and the request would fail with `InvalidSignatureException`. + +```bash +export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem +export AWS_ENDPOINT_URL_DYNAMODB=https://127.0.0.1:18443 +export AWS_DEFAULT_REGION=us-east-1 +export AWS_REGION=us-east-1 +export AWS_ACCESS_KEY_ID= +export AWS_SECRET_ACCESS_KEY= +aws dynamodb list-tables +``` + +```json +{ + "TableNames": [] +} +``` + +The management console is at `https://127.0.0.1:18443/console/`; log in as `admin` with the password `init` printed, or as `/alice` with the console password. + +The server is ready. [First requests](first-requests.md) walks through tables, items, batches, transactions and streams from here, and the [usage guide](manuals/03-usage-guide.md) has the SDK configuration for Java, Rust, JavaScript and Python. + +## Upgrading after a `git pull` + +When the new binary carries catalog migrations the deployment has not applied, `serve --foreground` and `verify` exit 3 and name the pending migrations; a daemon `serve` exits 1 with `Server failed to start: daemon process exited during startup` and writes the refusal to syslog. Stop the server before you migrate: `migrate --yes` waits up to 60 seconds (`--lock-timeout`) for a server of release 0.1.15 or later to stop and then exits 6, and it does not detect a server of an earlier release. + +```bash +./target/release/extenddb stop --config extenddb.toml +cargo build --release +./target/release/extenddb migrate --config extenddb.toml +./target/release/extenddb migrate --config extenddb.toml --yes +./target/release/extenddb serve --config extenddb.toml +``` + +The first `migrate` prints what is pending and changes nothing (exit status 3 when work is pending); the second applies it. Table data is not touched. The [upgrade manual](manuals/07-upgrade-manual.md) has the backup step, the rollback procedure and the per-release behavior changes. + +## Tear down + +Stop the server, then drop the databases. + +```bash +./target/release/extenddb stop --config extenddb.toml +./target/release/extenddb destroy --config extenddb.toml --yes --pg-user postgres +``` + +On PostgreSQL, `destroy` connects as the same administrator `init` used: pass the same `--pg-user`, with `EXTENDDB_PG_PASSWORD` set, and omit `--pg-user` where PostgreSQL runs as your own user. It drops both databases; the `extenddb` application role, `extenddb.toml` and the certificate under `~/.extenddb/tls/` are left in place and a later `init` reuses them. On MongoDB it drops the two databases through the configured connection string. On SQLite it removes the database file and its `-wal` and `-shm` files. It leaves the `.lock` file and the default backup store directory `backups/` beside them. Remove `backups/` too before a new `init`; otherwise the new server reports that store as owned by another catalog (see [`[backup.store]`](manuals/05-admin-guide.md#backupstore) in the administration guide). `--yes` is required; there is no interactive prompt. + +Stop the database you started in step 1: `docker stop extenddb-mongo extenddb-cassandra` for the containers, `brew services stop postgresql@17` or `brew services stop mongodb-community@7.0` on macOS, `sudo systemctl stop postgresql` or `sudo systemctl stop mongod` on Linux. + +On Cassandra, `destroy` has no way to take the superuser's credentials (it accepts only the PostgreSQL flags), so it cannot connect to a node with password authentication. Drop the keyspaces with `cqlsh` instead; `DESCRIBE KEYSPACES` lists them under the prefix, `extenddb_catalog` and `extenddb_account_` by default: + +```bash +docker exec extenddb-cassandra cqlsh -u cassandra -p cassandra \ + -e "DROP KEYSPACE extenddb_account_; DROP KEYSPACE extenddb_catalog; DROP ROLE extenddb;" +``` + +## Linux and macOS differences + +| Item | Linux | macOS (Homebrew) | +|---|---|---| +| PostgreSQL administrator | `postgres` (pass `--pg-user postgres`) | your user name (omit `--pg-user`) | +| Service manager | `systemctl` or `pg_ctl` | `brew services` or `pg_ctl` | +| Syslog reader | `journalctl -t extenddb` | `log stream --predicate 'processImagePath ENDSWITH "extenddb"'` | +| Socket directory in `pg_isready` | `/var/run/postgresql` | `/tmp` | + +## Troubleshooting + +| Symptom | Fix | +|---|---| +| `connection refused` on port 18443 | The server is not running: `./target/release/extenddb serve --config extenddb.toml` | +| A daemon `serve` exits 1 with `Server failed to start: daemon process exited during startup` and syslog names pending catalog migrations (`serve --foreground` exits 3 and prints them) | Stop any running server, then `./target/release/extenddb migrate --config extenddb.toml --yes`, then start the server | +| `role "postgres" does not exist` | PostgreSQL runs as your user: omit `--pg-user` | +| `password authentication failed for user "postgres"` or `Peer authentication failed for user "postgres"` | Give the `postgres` role a password and pass it in `EXTENDDB_PG_PASSWORD` ([Initialize on PostgreSQL](#initialize-on-postgresql)) | +| `Ident authentication failed for user "postgres"` | The same, and switch the `host` lines of `pg_hba.conf` from `ident` to `scram-sha-256` as [Initialize on PostgreSQL](#initialize-on-postgresql) shows | +| `Database '' already exists` from `init` | `./target/release/extenddb destroy --config extenddb.toml --yes`, with the same `--pg-user` as `init`, then `init` again | +| `destroy` hangs after a hard kill of the server | Stop the leftover `postgres` backends the killed server held (`ps -eo pid,command \| grep postgres`), then run `destroy` again | +| `UnrecognizedClientException` from the AWS CLI | The access key ID is unknown or inactive: check the ID `create-access-key` returned | +| `InvalidSignatureException` from the AWS CLI | The secret does not match the access key ID, or the client signs for another region than the server's `[server] region` | +| `AccessDeniedException` | The user's policy does not allow the operation | +| `ResourceNotFoundException` right after `create-table` | The table is still `CREATING`; `aws dynamodb wait table-exists --table-name ` | + +[Troubleshooting](troubleshooting.md) lists every startup, stop and runtime error message with its cause. + +--- + +## License + +Copyright 2026 ExtendDB contributors. Licensed under the Apache License, Version 2.0. +See [LICENSE](https://github.com/ExtendDB/extenddb/blob/main/LICENSE) for the full text. + +This software is provided "as is" without warranty of any kind. ExtendDB is an open +source project maintained by AWS. It is not Amazon DynamoDB or an AWS service. +"DynamoDB" is a trademark of Amazon.com, Inc. or its affiliates. diff --git a/docs/local-dev-docker-compose.md b/docs/local-dev-docker-compose.md index 5e273e2ca..c306782d9 100644 --- a/docs/local-dev-docker-compose.md +++ b/docs/local-dev-docker-compose.md @@ -1,5 +1,5 @@ --- -description: "Start the PostgreSQL image and a PostgreSQL container with one docker compose command, then create users, access keys and tables." +description: "Start the extenddb/extenddb-postgres image and a PostgreSQL container with one docker compose command, then create users and access keys and make the first requests." --- # Docker Compose with PostgreSQL @@ -115,13 +115,13 @@ docker compose exec extenddb extenddb manage \ --policy-name full-access \ --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"dynamodb:*","Resource":"*"}]}' -# Create an access key (shown once — save it) +# Create an access key (shown once; save it) docker compose exec extenddb extenddb manage \ --user admin --password 'ExtendDBLocalAdmin123' \ create-access-key --account-id --user-name myuser ``` -For the full management API reference, see [Admin Guide](manuals/05-admin-guide.md). +For the full management API reference, see [Administration](manuals/05-admin-guide.md). ## Configure AWS CLI @@ -134,7 +134,7 @@ export AWS_CA_BUNDLE=/tmp/extenddb-cert.pem aws dynamodb list-tables --endpoint-url https://127.0.0.1:18443 ``` -For more CLI examples, see [section 6 of the full walkthrough](getting-started.md#6-try-it-out); the table at the top of its section 5 lists the endpoint, certificate and credentials for a Compose server. +For more CLI examples, see [First requests](first-requests.md); the table at the top of that page lists the endpoint, certificate and credentials for a Compose server. ## View logs @@ -158,7 +158,7 @@ docker compose down -v ## ECR authentication -The PostgreSQL image is pulled from Amazon ECR Public. If the pull fails with an +The PostgreSQL server image is pulled from Amazon ECR Public. If the pull fails with an authorization error, reauthenticate: ```bash diff --git a/docs/local-mongodb-setup.md b/docs/local-mongodb-setup.md deleted file mode 100644 index 32a6da1cc..000000000 --- a/docs/local-mongodb-setup.md +++ /dev/null @@ -1,209 +0,0 @@ ---- -description: "Set up a single-node MongoDB replica set on a development machine for building and testing ExtendDB." ---- - -# Local MongoDB setup (development) - -## Prerequisites - -- MongoDB 7.0+ (for multi-document transactions) -- A replica set configuration (required even for single-node deployments) - -## Installation - -### macOS (Homebrew) - -```bash -brew tap mongodb/brew -brew install mongodb-community@7.0 -``` - -### Linux (Ubuntu/Debian) - -```bash -curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \ - sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor -echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] \ - https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | \ - sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list -sudo apt-get update && sudo apt-get install -y mongodb-org -``` - -### Docker (recommended for development) - -```bash -docker run -d --name extenddb-mongo \ - -p 127.0.0.1:27017:27017 \ - mongo:7 --replSet rs0 -``` - -## Replica Set Initialization - -MongoDB must run as a replica set for transactions and Change Streams. - -### Single-node replica set (development) - -```bash -# If using Docker: -docker exec extenddb-mongo mongosh --quiet --eval "rs.initiate()" - -# If using a local install: -mongosh --eval "rs.initiate()" -``` - -Wait a few seconds for the replica set to elect a primary, then verify: - -```bash -mongosh --eval "rs.status().ok" -# Should output: 1 -``` - -### Homebrew (macOS) with replica set - -Edit the MongoDB config to add replica set: - -```bash -# Find the config file -brew --prefix mongodb-community@7.0 -# Usually: /opt/homebrew/etc/mongod.conf -``` - -Add to `mongod.conf`: -```yaml -replication: - replSetName: rs0 -``` - -Restart and initiate: -```bash -brew services restart mongodb-community@7.0 -mongosh --eval "rs.initiate()" -``` - -## Connection Details - -| Setting | Value | -|---------|-------| -| Host | `localhost` | -| Port | `27017` | -| Replica set | `rs0` | -| Connection string | `mongodb://localhost:27017/?replicaSet=rs0` | - -For Docker on a non-default port: -``` -mongodb://localhost:27018/?replicaSet=rs0&directConnection=true -``` - -## Building with MongoDB Support - -The MongoDB backend is behind a feature flag. Backends are mutually exclusive -(a build enabling more than one is rejected at compile time), so disable the -default `postgres` feature: - -```bash -cargo build --release --no-default-features --features mongodb -``` - -The binary is single-backend; to run PostgreSQL and MongoDB side by side, build -one binary per backend. - -## Initializing ExtendDB with MongoDB - -`init` reads the MongoDB connection string from an existing `extenddb.toml`, so write the `[storage.mongodb]` section first and pass `--overwrite`: - -```bash -printf '[storage]\nbackend = "mongodb"\n\n[storage.mongodb]\nconnection_string = "mongodb://localhost:27017/?replicaSet=rs0"\n' > extenddb.toml -./target/release/extenddb init --backend mongodb --config extenddb.toml --overwrite -``` - -This creates: -- `extenddb_catalog` database (table metadata, IAM, settings) -- `extenddb_data` database (per-table item collections) -- Admin user credentials (printed to stdout) -- Self-signed TLS certificate at `~/.extenddb/tls/cert.pem` -- Config file `extenddb.toml` - -The generated config will contain: -```toml -[storage] -backend = "mongodb" - -[storage.mongodb] -connection_string = "mongodb://localhost:27017/?replicaSet=rs0" -``` - -## Starting the Server - -```bash -./target/release/extenddb serve --config extenddb.toml -``` - -## Config Mapping - -```toml -[storage] -backend = "mongodb" - -[storage.mongodb] -connection_string = "mongodb://localhost:27017/?replicaSet=rs0" -# max_connections = 50 -# max_catalog_connections = 20 -``` - -`max_connections` limits data-operation connections. The catalog and -authentication clients share a separate pool controlled by -`max_catalog_connections`, so size that value for their combined management -and authorization concurrency. - -Or via environment variable: -```bash -export EXTENDDB__STORAGE__MONGODB__CONNECTION_STRING="mongodb://localhost:27017/?replicaSet=rs0" -``` - -## Verifying the Connection - -`list-tables` needs an access key that this server issued. The server answers `UnrecognizedClientException` to any other key. Create one as in the [post-init workflow](getting-started.md#post-init-workflow) of the full walkthrough, then: - -```bash -# Health check -curl --cacert ~/.extenddb/tls/cert.pem https://127.0.0.1:18443/health - -# List tables (should return empty) -export AWS_ACCESS_KEY_ID= -export AWS_SECRET_ACCESS_KEY= -export AWS_REGION=us-east-1 -aws dynamodb list-tables \ - --endpoint-url https://127.0.0.1:18443 \ - --region us-east-1 -``` - -## Differences from PostgreSQL Backend - -- **Replica set required:** Even single-node MongoDB must be configured as a replica set. -- **DynamoDB Streams:** Inline record writes with atomic sequence numbers. -- **GSI propagation:** Synchronous inline updates during data operations. -- **Concurrency model:** Optimistic versioning with retry on conflict (vs row-level locking in PostgreSQL). - -## Stopping - -```bash -# ExtendDB -./target/release/extenddb stop --config extenddb.toml - -# Docker MongoDB -docker stop extenddb-mongo - -# Homebrew MongoDB -brew services stop mongodb-community@7.0 -``` - ---- - -## License - -Copyright 2026 ExtendDB contributors. Licensed under the Apache License, Version 2.0. -See [LICENSE](https://github.com/ExtendDB/extenddb/blob/main/LICENSE) for the full text. - -This software is provided "as is" without warranty of any kind. ExtendDB is an open -source project maintained by AWS. It is not Amazon DynamoDB or an AWS service. -"DynamoDB" is a trademark of Amazon.com, Inc. or its affiliates. diff --git a/docs/local-postgres-setup.md b/docs/local-postgres-setup.md deleted file mode 100755 index 9c50c54e7..000000000 --- a/docs/local-postgres-setup.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -description: "Set up a PostgreSQL instance on a development machine for building and testing ExtendDB." ---- - -# Local PostgreSQL setup (development) - -These notes set up a PostgreSQL instance on a development machine for building and testing ExtendDB. For a running server with PostgreSQL in containers see [Docker Compose with PostgreSQL](local-dev-docker-compose.md); for production deployments see the [deployment guide](manuals/11-deployment-guide.md). - -## Installation - -One worked example, PostgreSQL 15 from the PGDG repository on Amazon Linux 2 (any PostgreSQL 14 or newer works): - -```bash -sudo rpm -ivh --nodeps \ - https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm -sudo yum install -y --releasever=7 \ - --disablerepo="*" --enablerepo="pgdg15" \ - postgresql15-server postgresql15 -``` - -Binaries: `/usr/pgsql-15/bin/` - -## Data Directory - -``` -$HOME/pgdata -``` - -Initialized with: -```bash -/usr/pgsql-15/bin/initdb -D ~/pgdata --auth=trust --no-locale --encoding=UTF8 -``` - -Runs as the current user (not as `postgres` system user). - -You may need to add the current user to the `postgres` group; if initdb fails, check your logs. - -## Connection Details - -| Setting | Value | -|---------|-------| -| Host | `localhost` | -| Port | `5432` | -| Database | `extenddb_catalog` (the catalog database `init` creates) | -| User | `extenddb` | -| Password | `extenddb-local-dev` | -| Connection string | `postgresql://extenddb:extenddb-local-dev@localhost:5432/extenddb_catalog` | -| Admin user | the OS user that ran `initdb` (trusted via local socket) | - -## Starting / Stopping - -```bash -export PATH=/usr/pgsql-15/bin:$PATH - -# Start -pg_ctl -D ~/pgdata -l ~/pgdata/server.log start - -# Stop -pg_ctl -D ~/pgdata stop - -# Status -pg_ctl -D ~/pgdata status - -# Logs -tail -f ~/pgdata/server.log -``` - -## Authentication - -`pgdata/pg_hba.conf` is configured so: -- The `extenddb` user requires md5 password auth over TCP (`127.0.0.1`, `::1`) -- The OS user that ran `initdb` has trust auth for admin tasks -- Local socket connections use trust auth - -## Config Mapping - -`extenddb init` writes `extenddb.toml` with the catalog database it creates (`extenddb_catalog` by default). To point the server at the role above, edit the generated section: - -```toml -[storage.postgres] -connection_string = "postgresql://extenddb:extenddb-local-dev@localhost:5432/extenddb_catalog" -pool_size = 20 -``` - -Or via environment variable: -```bash -export EXTENDDB__STORAGE__POSTGRES__CONNECTION_STRING=\ -"postgresql://extenddb:extenddb-local-dev@localhost:5432/extenddb_catalog" -``` - ---- - -## License - -Copyright 2026 ExtendDB contributors. Licensed under the Apache License, Version 2.0. -See [LICENSE](https://github.com/ExtendDB/extenddb/blob/main/LICENSE) for the full text. - -This software is provided "as is" without warranty of any kind. ExtendDB is an open -source project maintained by AWS. It is not Amazon DynamoDB or an AWS service. -"DynamoDB" is a trademark of Amazon.com, Inc. or its affiliates. diff --git a/docs/manuals/03-usage-guide.md b/docs/manuals/03-usage-guide.md index 74cf1070e..3113e911b 100755 --- a/docs/manuals/03-usage-guide.md +++ b/docs/manuals/03-usage-guide.md @@ -112,7 +112,7 @@ aws dynamodb create-table \ }]' ``` -Tables transition through `CREATING` → `ACTIVE` status. The transition delay is configurable via the `control_plane_delay_seconds` runtime setting (default: 5 seconds). Poll with DescribeTable until `TableStatus` is `ACTIVE` before performing operations on the table. +Tables transition through `CREATING` → `ACTIVE` status. The transition delay is configurable via the `control_plane_delay_seconds` runtime setting (default: 0.25 seconds). Poll with DescribeTable until `TableStatus` is `ACTIVE` before performing operations on the table. ### DeleteTable @@ -375,7 +375,7 @@ aws dynamodb create-table \ Stream view types: `KEYS_ONLY`, `NEW_IMAGE`, `OLD_IMAGE`, `NEW_AND_OLD_IMAGES`. -**Important: SDK users need a separate `dynamodbstreams` client.** DynamoDB and DynamoDB Streams are separate services in every AWS SDK. Both clients must point at the same ExtendDB endpoint URL. See the [full walkthrough](../getting-started.md) for Python examples and the polling pattern. +**Important: SDK users need a separate `dynamodbstreams` client.** DynamoDB and DynamoDB Streams are separate services in every AWS SDK. Both clients must point at the same ExtendDB endpoint URL. See [First requests](../first-requests.md#dynamodb-streams) for Python examples and the polling pattern. Read stream records: diff --git a/docs/manuals/04-quickstart-setup-guide.md b/docs/manuals/04-quickstart-setup-guide.md deleted file mode 100755 index c9654cb4d..000000000 --- a/docs/manuals/04-quickstart-setup-guide.md +++ /dev/null @@ -1,433 +0,0 @@ ---- -description: "Clone, build, initialize and run ExtendDB from source in a few minutes, then set it up for regular use." ---- - -# Quick start from source - -> See [NOTICE](https://github.com/ExtendDB/extenddb/blob/main/docs/NOTICE.md) for important disclaimers. - -## Quick Start (5 Minutes) - -This section gets you from zero to a working ExtendDB instance as fast as possible. Detailed explanations follow in later chapters. - -### Prerequisites - -- PostgreSQL 14+ running locally -- Rust toolchain 1.91.1+ -- AWS CLI v2 - -### Steps - -```bash -# 1. Clone and build -git clone https://github.com/ExtendDB/extenddb.git && cd extenddb -cargo build --release - -# 2. Initialize (creates databases, admin user, TLS cert, config file) -./target/release/extenddb init - -# ⚠ Save the admin credentials and account ID printed here — shown once only! - -# 3. Verify -./target/release/extenddb verify --config extenddb.toml - -# 4. Start the server -./target/release/extenddb serve --config extenddb.toml - -# 5. Create an IAM user and access key -./target/release/extenddb manage --user admin --password \ - create-user --account-id \ - --user-name quickstart --user-password secret - -./target/release/extenddb manage --user admin --password \ - put-user-policy --account-id --user-name quickstart \ - --policy-name FullAccess \ - --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"dynamodb:*","Resource":"*"}]}' - -./target/release/extenddb manage --user /quickstart --password secret \ - create-access-key - -# 6. Configure AWS CLI (use access key from step 5) -export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem -export AWS_ENDPOINT_URL_DYNAMODB=https://127.0.0.1:18443 -export AWS_ACCESS_KEY_ID= -export AWS_SECRET_ACCESS_KEY= -export AWS_DEFAULT_REGION=us-east-1 - -# 7. Create a table -aws dynamodb create-table \ - --table-name QuickTest \ - --attribute-definitions AttributeName=pk,AttributeType=S \ - --key-schema AttributeName=pk,KeyType=HASH \ - --billing-mode PAY_PER_REQUEST -aws dynamodb wait table-exists --table-name QuickTest - -# 8. Insert an item -aws dynamodb put-item \ - --table-name QuickTest \ - --item '{"pk": {"S": "hello"}, "message": {"S": "extenddb is working!"}}' - -# 9. Read it back -aws dynamodb get-item \ - --table-name QuickTest \ - --key '{"pk": {"S": "hello"}}' -``` - -If step 9 returns the item written in step 8, ExtendDB is working. - -## Detailed Setup - -### PostgreSQL Installation - -ExtendDB requires PostgreSQL 14 or later. Install it for your platform: - -**Ubuntu/Debian:** - -```bash -sudo apt-get update -sudo apt-get install -y postgresql postgresql-client -sudo systemctl start postgresql -``` - -**macOS (Homebrew):** - -```bash -brew install postgresql@16 -brew services start postgresql@16 -``` - -**Amazon Linux 2:** - -```bash -sudo amazon-linux-extras install postgresql14 -sudo systemctl start postgresql -``` - -Verify PostgreSQL is running: - -```bash -psql -U postgres -c "SELECT version();" -``` - -### PostgreSQL User Setup - -`extenddb init` creates a `extenddb` PostgreSQL user automatically. If you prefer to create it manually: - -```bash -sudo -u postgres createuser --createdb extenddb -sudo -u postgres psql -c "ALTER USER extenddb WITH PASSWORD 'extenddb-local-dev';" -``` - -### Building ExtendDB - -```bash -# Debug build (faster compilation, slower runtime) -cargo build - -# Release build (slower compilation, optimized runtime) -cargo build --release -``` - -The binary is at `target/release/extenddb` (or `target/debug/extenddb`). - -Check the version: - -```bash -./target/release/extenddb version -# extenddb 1.0.0 -# catalog migration 12 (postgres) -# commit abc1234 -# built 2026-04-17T12:00:00Z -# test-hooks disabled -``` - -### Initialization - -`extenddb init` creates the catalog and data databases, runs schema migrations, generates an encryption key, creates a default account, and creates an admin user. - -```bash -./target/release/extenddb init -``` - -Options: - -| Flag | Default | Description | -|------|---------|-------------| -| `--catalog-db` | `extenddb_catalog` | Catalog database name | -| `--data-db` | the catalog's name without `_catalog` (`extenddb` for the default catalog) | Data database name | -| `--pg-host` | `localhost` | PostgreSQL host | -| `--pg-port` | `5432` | PostgreSQL port | -| `--pg-user` | `$USER`, then `postgres` | PostgreSQL admin role, used for `CREATE DATABASE` and `CREATE USER` | -| `--pg-pass` | none (or `EXTENDDB_PG_PASSWORD`) | The admin role's password | -| `--extenddb-user` | `extenddb` | The application role the server connects as | -| `--extenddb-pass` | `extenddb-local-dev` (or `EXTENDDB_APP_PASSWORD`) | The application role's password | - -The command generates `extenddb.toml` with the connection details. If `extenddb.toml` already exists, `init` refuses (`Error: Config file "extenddb.toml" already exists. Use --overwrite to delete and regenerate it.`, exit 255); with `--overwrite` it loads the PostgreSQL connection defaults from the existing file and writes a new one. - -**Save the admin credentials** printed during init. They are shown once and cannot be retrieved later. - -### Verification - -```bash -./target/release/extenddb verify --config extenddb.toml -``` - -Expected output: - -``` -=== extenddb verify === -Config: extenddb.toml -Catalog database: extenddb_catalog - ---- Checking catalog migrations... - OK: Current: the catalog is at migration 12 ---- Checking catalog connection... - OK: Connected to catalog. ---- Checking data database... - OK: Connected to data database 'extenddb'. ---- Enumerating tables... - Tables: 0 - Indexes: 0 - -=== HEALTHY: All checks passed === -``` - -### Starting the Server - -```bash -./target/release/extenddb serve --config extenddb.toml -``` - -ExtendDB runs as a daemon (background process). It prints a startup banner, then forks to background. All logging goes to syslog. - -Check status: - -```bash -./target/release/extenddb status --config extenddb.toml -``` - -Read logs: - -**Linux:** - -```bash -journalctl -t extenddb -f -``` - -**macOS:** - -```bash -# Live stream -log stream --predicate 'processImagePath ENDSWITH "extenddb"' --level info - -# Historical -log show --predicate 'processImagePath ENDSWITH "extenddb"' --last 1h -``` - -### Stopping the Server - -```bash -./target/release/extenddb stop --config extenddb.toml -``` - -Alternatively, find the PID and send SIGTERM manually: - -```bash -./target/release/extenddb status --config extenddb.toml -kill -``` - -### AWS CLI Configuration - -ExtendDB uses TLS with a self-signed certificate. Set `AWS_CA_BUNDLE` to trust it: - -```bash -export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem -``` - -Three options for endpoint configuration, from simplest to most structured: - -**Option A: Environment variables** - -```bash -export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem -export AWS_ENDPOINT_URL_DYNAMODB=https://127.0.0.1:18443 -export AWS_ACCESS_KEY_ID= -export AWS_SECRET_ACCESS_KEY= -export AWS_DEFAULT_REGION=us-east-1 -``` - -**Option B: AWS config profile** - -`~/.aws/config`: - -```ini -[profile extenddb] -region = us-east-1 -ca_bundle = ~/.extenddb/tls/cert.pem -services = extenddb-services - -[services extenddb-services] -dynamodb = - endpoint_url = https://127.0.0.1:18443 -``` - -`~/.aws/credentials`: - -```ini -[extenddb] -aws_access_key_id = -aws_secret_access_key = -``` - -Then: `export AWS_PROFILE=extenddb` - -**Option C: Per-command `--endpoint-url`** - -```bash -export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem -aws dynamodb list-tables --endpoint-url https://127.0.0.1:18443 -``` - -### Setting Up Credentials - -ExtendDB ships with builtin IAM authentication enabled. After `extenddb init`, create an IAM user and access key: - -```bash -# Create an account (--account-id is optional; auto-generated if omitted) -./target/release/extenddb manage --user admin --password \ - create-account --account-name dev-team -# Account ID: ← save this - -# Create an IAM user with console password -./target/release/extenddb manage --user admin --password \ - create-user --account-id \ - --user-name alice --user-password secret - -# Grant DynamoDB full access -./target/release/extenddb manage --user admin --password \ - put-user-policy --account-id \ - --user-name alice \ - --policy-name FullAccess \ - --policy-document '{ - "Version": "2012-10-17", - "Statement": [{ - "Effect": "Allow", - "Action": "dynamodb:*", - "Resource": "*" - }] - }' - -# Create an access key (self-service — inferred from --user) -./target/release/extenddb manage --user /alice --password secret \ - create-access-key -# Save the access key ID and secret key! -``` - -Configure your SDK with the access key and secret key: - -```bash -export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem -export AWS_ACCESS_KEY_ID= -export AWS_SECRET_ACCESS_KEY= -export AWS_DEFAULT_REGION=us-east-1 -``` - -5. Create a table with streams enabled: - -```bash -aws dynamodb create-table \ - --table-name StreamTest \ - --attribute-definitions AttributeName=pk,AttributeType=S \ - --key-schema AttributeName=pk,KeyType=HASH \ - --billing-mode PAY_PER_REQUEST \ - --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES \ - --endpoint-url https://127.0.0.1:18443 -``` - -6. Wait for the table to become ACTIVE, then insert an item: - -```bash -aws dynamodb put-item \ - --table-name StreamTest \ - --item '{"pk": {"S": "key1"}, "data": {"S": "hello streams"}}' \ - --endpoint-url https://127.0.0.1:18443 -``` - -7. Read the stream: - -```bash -# List streams -aws dynamodbstreams list-streams \ - --table-name StreamTest \ - --endpoint-url https://127.0.0.1:18443 - -# Describe the stream (use the StreamArn from above) -aws dynamodbstreams describe-stream \ - --stream-arn \ - --endpoint-url https://127.0.0.1:18443 - -# Get a shard iterator (use the ShardId from above) -aws dynamodbstreams get-shard-iterator \ - --stream-arn \ - --shard-id \ - --shard-iterator-type TRIM_HORIZON \ - --endpoint-url https://127.0.0.1:18443 - -# Get records (use the ShardIterator from above) -aws dynamodbstreams get-records \ - --shard-iterator \ - --endpoint-url https://127.0.0.1:18443 -``` - -### Management Web Console - -Navigate to `https://127.0.0.1:18443/console/` in your browser. Log in with admin credentials or IAM user credentials (`account_id/user_name`). - -The console provides a GUI for managing accounts, users, groups, roles, policies, and access keys. - -### Runtime Settings - -Adjust behavior without restarting: - -```bash -# Reduce table transition delay for faster test cycles -./target/release/extenddb settings --config extenddb.toml set \ - control_plane_delay_seconds 2 - -# Change log level -./target/release/extenddb settings --config extenddb.toml set log_level debug -``` - -Changes take effect within 30 seconds. - -### Tear Down - -```bash -./target/release/extenddb destroy --config extenddb.toml -``` - -This drops both databases after confirmation. - -## Troubleshooting Quick Reference - -| Symptom | Fix | -|---------|-----| -| `connection refused` on port 18443 | Server not running. Start with `extenddb serve --config extenddb.toml` | -| `serve` exits 3, naming pending catalog migrations | Run `extenddb migrate --config extenddb.toml --yes`, then start the server | -| `ResourceNotFoundException` on CreateTable | Table is still in CREATING status. Poll DescribeTable until `TableStatus` is `ACTIVE` | -| `UnrecognizedClientException` | Invalid access key. Check credentials: verify the access key ID and secret match what was returned by `create-access-key` | -| `AccessDeniedException` | IAM policy does not allow the operation. Attach a policy with the required permissions | - -See [Troubleshooting](../troubleshooting.md) for the full troubleshooting guide. - ---- - -## License - -Copyright 2026 ExtendDB contributors. Licensed under the Apache License, Version 2.0. -See [LICENSE](https://github.com/ExtendDB/extenddb/blob/main/LICENSE) for the full text. - -This software is provided "as is" without warranty of any kind. ExtendDB is an open -source project maintained by AWS. It is not Amazon DynamoDB or an AWS service. -"DynamoDB" is a trademark of Amazon.com, Inc. or its affiliates. diff --git a/docs/manuals/05-admin-guide.md b/docs/manuals/05-admin-guide.md index d3bc853af..d513739c6 100755 --- a/docs/manuals/05-admin-guide.md +++ b/docs/manuals/05-admin-guide.md @@ -325,13 +325,16 @@ Precedence: CLI flags > environment variables > config file > defaults. ### Runtime Settings -Managed via `extenddb settings set`. Changes take effect within 30 seconds without restart. +Managed via `extenddb settings set`. Changes take effect within 30 seconds without restart. A running server logs, under no audit target, when it applies a new `log_level`, `sqlx_log_level` or `throttling_enabled` value. | Setting | Default | Description | |---------|---------|-------------| | `log_level` | `info` | Log level: trace, debug, info, warn, error | +| `sqlx_log_level` | `warn` | Log level for sqlx query traces, independent of `log_level`: trace, debug, info, warn, error | | `control_plane_delay_seconds` | `0.25` | Delay for table status transitions, in seconds (0 = instant). PostgreSQL and SQLite write 0.25 into the catalog when it is created; MongoDB and Cassandra use 0.25 when the setting is absent. On PostgreSQL and SQLite a value below 1 makes DeleteTable remove the table in the request; on PostgreSQL, if a session holds a lock on the table's data (a reader, an open write transaction, an index build), DeleteTable returns `DELETING` instead (after at most about a second), the drop finishes in the background within about a second of that session's release, and a CreateTable of the same name is refused until then. | | `allow_credential_import` | `false` | Whether `import-access-key` is allowed. Only `true` enables it | +| `index_propagation_delay_ms` | `10` | Delay before an asynchronous GSI update is applied (0 = synchronous). The pre-rename key `gsi_propagation_delay_ms` is still accepted and writes to the same row | +| `throttling_enabled` | `false` | Enforce provisioned throughput limits with a token bucket per table and partition | | `vector_backfill_batch_delay_ms` | `0` | **Test-oriented.** Milliseconds to pause between batches while a vector index backfills. Zero in production. A test sets it so a write is guaranteed to land while the index is still building. The pause is outside the batch transaction, so writes are still accepted throughout, but it does extend the per-table propagation hold: no index on that table advances while the build runs, GSIs included, and the accepted range goes up to 60 s per batch. | | `vector_allocation_phase_delay_ms` | `0` | **Test-oriented.** Milliseconds to hold a new vector index in the resource-allocation phase (`CREATING` with `Backfilling: false`) before the scan starts. Zero in production. Without it the phase lasts only from the `UpdateTable` transaction, which inserts the row as `CREATING` with `Backfilling: false`, until the detached build task flips the flag, which is a window no client can time reliably rather than one that cannot exist. | @@ -360,8 +363,148 @@ history, CI logs and pasted transcripts. `set` refuses `encryption_key` and `encryption_key_ring`; the [Encryption Key](#encryption-key) commands are the one way to change them. +#### sqlx log separation + +sqlx query traces are suppressed by default (level `warn`) so they don't flood the main log stream. The sqlx log level is independently configurable via the `sqlx_log_level` runtime setting: + +```bash +# Enable sqlx debug logging for query troubleshooting +./target/release/extenddb settings --config extenddb.toml set sqlx_log_level debug + +# Restore default (suppress most sqlx output) +./target/release/extenddb settings --config extenddb.toml set sqlx_log_level warn +``` + +When sqlx logging is enabled, messages appear in the `extenddb` syslog with `sqlx::query` as the target. Filter them: + +```bash +# Exclude sqlx messages +journalctl -t extenddb | grep -v sqlx + +# Show only sqlx messages +journalctl -t extenddb | grep sqlx +``` + +#### Control plane delay + +By default, control plane operations (CreateTable, DeleteTable) emulate the service's asynchronous behavior: tables transition through CREATING to ACTIVE and DELETING to removed states over a configurable delay (default: 0.25 seconds). Adjust with: + +```bash +# Set to 0 for instant transitions (useful for fast test cycles) +./target/release/extenddb settings --config extenddb.toml set \ + control_plane_delay_seconds 0 + +# Set to 10 seconds for more realistic behavior +./target/release/extenddb settings --config extenddb.toml set \ + control_plane_delay_seconds 10 +``` + +#### Warm throughput + +`WarmThroughput` on `CreateTable`, `UpdateTable` and `GlobalSecondaryIndexUpdates` is stored and reported on `DescribeTable` with the shape, defaults (12000 read and 4000 write units on an on-demand table, the provisioned units on a provisioned one) and validation of Amazon DynamoDB, and `Status` reads `UPDATING` for the control plane delay after a change, then `ACTIVE`. Nothing acts on the values: there is no pre-warming and no scaling at the database level, and they have no effect on throughput, throttling or storage. + +#### GSI propagation delay + +On PostgreSQL, SQLite and Cassandra, GSI updates are applied asynchronously after a configurable delay, simulating the DynamoDB service's eventually consistent GSI behavior. The system-wide default is 10 ms, and each GSI can override it with a per-index `propagation_delay_ms` stored in the catalog. MongoDB maintains GSIs in the write itself and reads no delay. + +```bash +# Set system-wide default to 0 for synchronous GSI updates (fast tests) +./target/release/extenddb settings --config extenddb.toml set \ + index_propagation_delay_ms 0 + +# Set to 50ms for more realistic eventual consistency +./target/release/extenddb settings --config extenddb.toml set \ + index_propagation_delay_ms 50 +``` + +#### Throttling + +ExtendDB enforces provisioned throughput limits using a token bucket per table and partition, matching DynamoDB's burst and refill behavior. Throttling is disabled by default. The `throttling_enabled` key in the `[server]` section of `extenddb.toml` sets the value the server starts with; once the runtime setting has been written it takes precedence. + +```bash +# Enable throttling (production-like behavior) +./target/release/extenddb settings --config extenddb.toml set \ + throttling_enabled true + +# Disable throttling (useful for bulk loading) +./target/release/extenddb settings --config extenddb.toml set \ + throttling_enabled false +``` + +#### TTL deletion + +Expired items are removed by a TTL sweeper that runs every 60 seconds. Each sweep finds expired items through the table's TTL index and deletes up to 100 per table on PostgreSQL, MongoDB and SQLite (1,000 on Cassandra), so a table with a small backlog is cleared within about a minute of expiry and a larger backlog drains at that rate per table per minute. The interval is fixed: there is no `ttl_deletion_target_seconds` runtime setting, and `extenddb settings set` rejects that key. + ## IAM Management +The management API is available at `/management/*` on the running ExtendDB server. The `extenddb manage` CLI subcommand is a thin client that calls these endpoints. + +Admin commands require admin credentials (the username and password printed during `extenddb init`). IAM user self-service commands accept `account_id/user_name` as the `--user` value. + +**Note:** The `--password` flag is visible in process listings (`ps aux`) and shell history. For sensitive environments, leave out `--password` and set the `EXTENDDB_PASSWORD` environment variable instead, with `read -rs EXTENDDB_PASSWORD && export EXTENDDB_PASSWORD`, which keeps the password out of shell history. `extenddb manage` reads the password from `EXTENDDB_PASSWORD`, and it prints a warning on stderr when it gets `--password`. `--admin-password`, `--new-password`, `--user-password` and `--secret-access-key` have no environment variable. + +### Using a custom endpoint + +By default, `extenddb manage` reads the server address from `extenddb.toml` (`--config` selects another file). To target a different server: + +```bash +./target/release/extenddb manage --user admin --password \ + --endpoint 127.0.0.1:9000 list-admins +``` + +### Command index + +Every `extenddb manage` subcommand, grouped as in the sections below. + +| Command | Purpose | +|---------|---------| +| `manage create-admin` | Create a new admin user | +| `manage list-admins` | List admin users | +| `manage delete-admin` | Delete an admin user | +| `manage change-admin-password` | Change an admin user's password | +| `manage create-account` | Create a new account | +| `manage list-accounts` | List accounts | +| `manage delete-account` | Delete an account | +| `manage create-user` | Create an IAM user | +| `manage list-users` | List IAM users in an account | +| `manage delete-user` | Delete an IAM user | +| `manage change-user-password` | Change an IAM user's password (self-service or admin) | +| `manage create-access-key` | Create an access key (self-service or admin) | +| `manage list-access-keys` | List access keys (self-service or admin) | +| `manage delete-access-key` | Delete an access key (self-service or admin) | +| `manage import-access-key` | Import an existing access key | +| `manage create-group` | Create an IAM group | +| `manage list-groups` | List IAM groups in an account | +| `manage delete-group` | Delete an IAM group | +| `manage add-group-member` | Add a user to a group | +| `manage remove-group-member` | Remove a user from a group | +| `manage create-role` | Create an IAM role | +| `manage list-roles` | List IAM roles in an account | +| `manage delete-role` | Delete an IAM role | +| `manage assume-role` | Assume an IAM role and get temporary credentials | +| `manage put-user-policy` | Put a user policy (creates or replaces) | +| `manage list-user-policies` | List user policies | +| `manage delete-user-policy` | Delete a user policy | +| `manage put-group-policy` | Put a group policy (creates or replaces) | +| `manage list-group-policies` | List group policies | +| `manage delete-group-policy` | Delete a group policy | +| `manage put-role-policy` | Put a role policy (creates or replaces) | +| `manage list-role-policies` | List role policies | +| `manage delete-role-policy` | Delete a role policy | +| `manage set-user-boundary` | Set a user permissions boundary | +| `manage get-user-boundary` | Get a user permissions boundary | +| `manage delete-user-boundary` | Delete a user permissions boundary | +| `manage set-role-boundary` | Set a role permissions boundary | +| `manage get-role-boundary` | Get a role permissions boundary | +| `manage delete-role-boundary` | Delete a role permissions boundary | +| `manage tag-user` | Tag an IAM user | +| `manage untag-user` | Untag an IAM user | +| `manage list-user-tags` | List tags for an IAM user | +| `manage tag-role` | Tag an IAM role | +| `manage untag-role` | Untag an IAM role | +| `manage list-role-tags` | List tags for an IAM role | +| `manage cache` | Cache management (admin-only break-glass invalidation) | + ### Admin Users Admin users authenticate to the management API and web console. They have full access to all management operations. @@ -404,6 +547,8 @@ Account IDs must be 12-digit numeric strings (matching AWS format). If `--accoun delete-account --account-id 123456789012 ``` +Deleting an account also deletes its users, groups and roles with everything they hold, so their access keys and sessions stop working and its users cannot log in. An account created later with the same ID starts empty. + ### IAM Users ```bash @@ -419,13 +564,28 @@ Account IDs must be 12-digit numeric strings (matching AWS format). If `--accoun # Delete (also removes its keys, memberships, tags, policies and boundary) ./target/release/extenddb manage --user admin --password \ delete-user --account-id 123456789012 --user-name alice + +# Change password (self-service or admin) +./target/release/extenddb manage --user 123456789012/alice --password secret \ + change-user-password --account-id 123456789012 \ + --user-name alice --new-password newsecret ``` +Deleting a user also removes its access keys, group memberships, tags, inline policies, permissions boundary and failed login attempts. A user created later with the same name starts with only the default `SelfServicePolicy`, and is not refused for the failed logins of the deleted one. + +If `--user-password` is provided, the user can authenticate to the management API for self-service operations. A default self-service policy is automatically attached, allowing the user to create and delete their own access keys and change their own password. + ### Access Keys +IAM users create their own access keys by authenticating with `account_id/user_name:password`. When authenticating as an IAM user, `--account-id` and `--user-name` are inferred automatically. The secret key is shown once and cannot be retrieved later. + ```bash -# Create (self-service or admin) +# Create (self-service: account_id and user_name inferred from --user) ./target/release/extenddb manage --user 123456789012/alice --password secret \ + create-access-key + +# Create (admin, on behalf of any user) +./target/release/extenddb manage --user admin --password \ create-access-key --account-id 123456789012 --user-name alice # List @@ -446,7 +606,12 @@ Account IDs must be 12-digit numeric strings (matching AWS format). If `--accoun --secret-access-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY --yes ``` -Access key prefixes: `AKIAEXTENDDB` (long-lived), `ASIAEXTENDDB` (temporary/AssumeRole). +Generated access keys carry ExtendDB-specific prefixes that distinguish them from AWS credentials: +- Long-lived keys: `AKIAEXTENDDB` + 8 random chars (20 total) +- Temporary credentials (AssumeRole): `ASIAEXTENDDB` + 8 random chars (20 total) +- Secret keys: `extenddb` + 32 random chars (40 total) + +`import-access-key` imports AWS credentials (or any AKIA* key) into ExtendDB. This enables the "change only the endpoint URL" workflow: the same credentials work against ExtendDB and the DynamoDB service. Both `--secret-access-key` and `--yes` are required. `--secret-access-key` and `--password` are visible in `ps` output and shell history; for sensitive environments, set the password with `read -rs EXTENDDB_PASSWORD && export EXTENDDB_PASSWORD` and leave out `--password`. `--secret-access-key` has no environment variable. Credential import is gated by the `allow_credential_import` runtime setting (default: `false`; see [Runtime Settings](#runtime-settings)): enable it before the first import, as above, and set it back to `false` to refuse further imports. Keys already imported keep working. Credential import is not audit-logged (see [Audit Logging](#audit-logging)). ### Groups @@ -465,11 +630,17 @@ Access key prefixes: `AKIAEXTENDDB` (long-lived), `ASIAEXTENDDB` (temporary/Assu remove-group-member --account-id 123456789012 \ --group-name developers --user-name alice +# List +./target/release/extenddb manage --user admin --password \ + list-groups --account-id 123456789012 + # Delete (also removes its policies and memberships) ./target/release/extenddb manage --user admin --password \ delete-group --account-id 123456789012 --group-name developers ``` +A group created later with the same name starts with no policies and no members. + ### Roles ```bash @@ -483,21 +654,46 @@ Access key prefixes: `AKIAEXTENDDB` (long-lived), `ASIAEXTENDDB` (temporary/Assu "Principal": { "AWS": "arn:aws:iam::123456789012:user/alice" }, - "Action": "sts:AssumeRole" + "Action": ["sts:AssumeRole", "sts:TagSession"] }] }' +# List +./target/release/extenddb manage --user admin --password \ + list-roles --account-id 123456789012 + # Assume role (generates temporary ASIA* credentials) ./target/release/extenddb manage --user admin --password \ assume-role --account-id 123456789012 --role-name data-reader \ --caller-arn arn:aws:iam::123456789012:user/alice \ --session-name test-session +# Assume role with optional session tags, session policy and duration +# (--duration-seconds defaults to 3600) +./target/release/extenddb manage --user admin --password \ + assume-role --account-id 123456789012 --role-name data-reader \ + --caller-arn arn:aws:iam::123456789012:user/alice \ + --session-name test-session \ + --session-tags '{"Project":"Alpha"}' \ + --session-policy '{ + "Version": "2012-10-17", + "Statement": [{ + "Effect": "Allow", + "Action": "dynamodb:GetItem", + "Resource": "*" + }] + }' \ + --duration-seconds 1800 + # Delete (also removes its policies, boundary, tags and sessions) ./target/release/extenddb manage --user admin --password \ delete-role --account-id 123456789012 --role-name data-reader ``` +The trust policy must allow the caller ARN for `assume-role` to succeed. + +Deleting a role also removes its inline policies, permissions boundary, tags and sessions: credentials issued by `assume-role` stop working. A role created later with the same name starts with none of them. + #### What a trust-policy Deny matches A role's trust policy decides who may assume the role. It is evaluated in IAM @@ -506,8 +702,9 @@ considered, and with no matching `Allow` assumption is implicitly denied. The decision is made for each STS action the call exercises: `sts:AssumeRole` always, and `sts:TagSession` as well when the call passes session tags. Passing session tags to a role whose trust policy does not allow `sts:TagSession` is -denied. ExtendDB does not implement source identity, so `sts:SetSourceIdentity` -is never part of the decision. +denied with 403 `Caller is not authorized to assume this role`. ExtendDB does +not implement source identity, so `sts:SetSourceIdentity` is never part of the +decision. A statement matches when its `Principal` matches the caller, its `Action` (or `NotAction`) covers the action, and all `Condition` blocks pass. `Effect` is @@ -603,8 +800,29 @@ or `IAM role not found`), as IAM answers `NoSuchEntity`. "Resource": "*" }] }' + +# List policies +./target/release/extenddb manage --user admin --password \ + list-user-policies --account-id 123456789012 --user-name alice +./target/release/extenddb manage --user admin --password \ + list-group-policies --account-id 123456789012 --group-name developers +./target/release/extenddb manage --user admin --password \ + list-role-policies --account-id 123456789012 --role-name data-reader + +# Delete policies +./target/release/extenddb manage --user admin --password \ + delete-user-policy --account-id 123456789012 \ + --user-name alice --policy-name ReadOnly +./target/release/extenddb manage --user admin --password \ + delete-group-policy --account-id 123456789012 \ + --group-name developers --policy-name FullAccess +./target/release/extenddb manage --user admin --password \ + delete-role-policy --account-id 123456789012 \ + --role-name data-reader --policy-name ReadOnly ``` +The policy document must be valid JSON with `Version` and `Statement` fields. `put-*-policy` creates or replaces the named policy. + #### Condition keys in identity policies Identity-policy conditions on DynamoDB requests follow the same rule as trust @@ -935,6 +1153,27 @@ deny `dynamodb:PutItem` on it instead. # Delete boundary ./target/release/extenddb manage --user admin --password \ delete-user-boundary --account-id 123456789012 --user-name alice + +# Set role boundary +./target/release/extenddb manage --user admin --password \ + set-role-boundary --account-id 123456789012 \ + --role-name data-reader \ + --policy-document '{ + "Version": "2012-10-17", + "Statement": [{ + "Effect": "Allow", + "Action": "dynamodb:GetItem", + "Resource": "*" + }] + }' + +# Get role boundary +./target/release/extenddb manage --user admin --password \ + get-role-boundary --account-id 123456789012 --role-name data-reader + +# Delete role boundary +./target/release/extenddb manage --user admin --password \ + delete-role-boundary --account-id 123456789012 --role-name data-reader ``` ### Tags @@ -952,6 +1191,37 @@ deny `dynamodb:PutItem` on it instead. # Untag ./target/release/extenddb manage --user admin --password \ untag-user --account-id 123456789012 --user-name alice --tag-keys Department + +# Tag a role +./target/release/extenddb manage --user admin --password \ + tag-role --account-id 123456789012 --role-name data-reader \ + --tags '[{"key":"Team","value":"Backend"}]' + +# List role tags +./target/release/extenddb manage --user admin --password \ + list-role-tags --account-id 123456789012 --role-name data-reader + +# Untag a role +./target/release/extenddb manage --user admin --password \ + untag-role --account-id 123456789012 --role-name data-reader --tag-keys Team +``` + +### Cache Invalidation + +`manage cache invalidate` is an admin-only break-glass path that evicts entries from the in-memory authorization caches described in the `[auth.cache]` configuration section above. Use it when a change made outside the management API (a direct catalog write, or a mutation on another instance) must take effect before `ttl_seconds` elapses. Scopes: `all` (requires `--yes`), `account`, `credential`, `user`, `role`, `group-members`, `table-key-info` and `resource-tags`; `cache invalidate --help` lists the flags each one takes. + +```bash +# One credential +./target/release/extenddb manage --user admin --password \ + cache invalidate credential --access-key-id AKIAEXTENDDB... + +# Everything cached about a user +./target/release/extenddb manage --user admin --password \ + cache invalidate user --account-id 123456789012 --user-name alice + +# Every cache (global flush) +./target/release/extenddb manage --user admin --password \ + cache invalidate all --yes ``` ## Encryption Key @@ -1118,6 +1388,10 @@ Core dumps stay on: `MADV_DONTDUMP` keeps the core and excludes the key pages, s The management web console is served at `/console/` on the same port as the DynamoDB API. It requires `auth.provider = "builtin"`. +### Accessing the console + +Navigate to `https://127.0.0.1:18443/console/` in your browser (adjust the host and port to match your `extenddb.toml` configuration). Accept the self-signed certificate warning on first visit. + ### Features - **Dashboard**: Account and admin user counts (admin sessions only; an IAM-user session gets a link to its own user page), version info @@ -1132,10 +1406,12 @@ The management web console is served at `/console/` on the same port as the Dyna ### Authentication -- Admin users: enter username and password +- Admin users: enter username and password (the credentials printed during `extenddb init`) - IAM users: enter `account_id/user_name` as username, console password as password -Sessions end 8 hours after login. Click "Logout" to end immediately. Deleting an admin or IAM user, or changing its password, ends its console sessions on every server at their next request. +Admin users have full access to all management operations. IAM users open their own user page, which lists their access keys, and create and delete their own access keys there. These are the access key reads and writes the management API gives an IAM user. The console has no form to change the password or import a key. + +Sessions end 8 hours after login. Click "Logout" to end a session immediately. Deleting an admin or IAM user, or changing its password, ends its console sessions on every server at their next request. ## Monitoring @@ -1178,10 +1454,17 @@ The server logs some management operations, and the settings changes made throug ```bash # View audit entries +# Linux journalctl -t extenddb | grep 'extenddb::audit' + +# macOS +log show --predicate 'processImagePath ENDSWITH "extenddb"' --last 1d | grep 'extenddb::audit' + +# Docker Compose (--foreground) +docker compose logs extenddb | grep 'extenddb::audit' ``` -Targets: `extenddb::audit::manage` (some management operations), `extenddb::audit::settings` (settings changes made through the management API). +Targets: `extenddb::audit::manage` (some management operations), `extenddb::audit::settings` (settings changes made through the management API). Secrets (passwords, secret keys) are never included in audit log entries. ### Metrics diff --git a/docs/manuals/06-developer-test-guide.md b/docs/manuals/06-developer-test-guide.md index 125edea1a..b1047d0bd 100755 --- a/docs/manuals/06-developer-test-guide.md +++ b/docs/manuals/06-developer-test-guide.md @@ -122,6 +122,101 @@ Activate the virtual environment before running any test suites: source ~/venvs/extenddb-venv/bin/activate ``` +### Local databases for the test suite + +The integration suites run against a server backed by a local PostgreSQL or MongoDB. Installing either database is covered in [Installing from source](../install-from-source.md); this section records the connection details and configuration the test setup assumes. + +#### PostgreSQL + +| Setting | Value | +|---------|-------| +| Host | `localhost` | +| Port | `5432` | +| Database | `extenddb_catalog` (the catalog database `init` creates) | +| User | `extenddb` | +| Password | `extenddb-local-dev` | +| Connection string | `postgresql://extenddb:extenddb-local-dev@localhost:5432/extenddb_catalog` | +| Admin user | the OS user that ran `initdb` (trusted via local socket) | + +The paths below are the Amazon Linux 2 setup from the install page (PostgreSQL 15 from the PGDG repository, data directory `~/pgdata`, running as the current user). If `initdb` fails there, the current user may need to be in the `postgres` group; check its log. + +```bash +export PATH=/usr/pgsql-15/bin:$PATH + +# Start +pg_ctl -D ~/pgdata -l ~/pgdata/server.log start + +# Stop +pg_ctl -D ~/pgdata stop + +# Status +pg_ctl -D ~/pgdata status + +# Logs +tail -f ~/pgdata/server.log +``` + +`initdb --auth=trust` gives every local and TCP connection trust authentication, so neither the admin role nor `extenddb` needs a password on this machine. Use it only on a machine no one else can reach. + +`extenddb init` writes `extenddb.toml` with the catalog database it creates (`extenddb_catalog` by default). To point the server at the role above, edit the generated section: + +```toml +[storage.postgres] +connection_string = "postgresql://extenddb:extenddb-local-dev@localhost:5432/extenddb_catalog" +pool_size = 20 +``` + +Or via environment variable: +```bash +export EXTENDDB__STORAGE__POSTGRES__CONNECTION_STRING=\ +"postgresql://extenddb:extenddb-local-dev@localhost:5432/extenddb_catalog" +``` + +#### MongoDB + +```toml +[storage] +backend = "mongodb" + +[storage.mongodb] +connection_string = "mongodb://localhost:27017/?replicaSet=rs0" +# max_connections = 50 +# max_catalog_connections = 20 +``` + +`max_connections` limits data-operation connections. The catalog and +authentication clients share a separate pool controlled by +`max_catalog_connections`, so size that value for their combined management +and authorization concurrency. + +Or via environment variable: +```bash +export EXTENDDB__STORAGE__MONGODB__CONNECTION_STRING="mongodb://localhost:27017/?replicaSet=rs0" +``` + +Verify the connection once the server is up. `list-tables` needs an access key that this server issued. The server answers `UnrecognizedClientException` to any other key. Create one as in the [smoke test](../install-from-source.md#6-smoke-test) of the install page, then: + +```bash +# Health check +curl --cacert ~/.extenddb/tls/cert.pem https://127.0.0.1:18443/health + +# List tables (should return empty) +export AWS_ACCESS_KEY_ID= +export AWS_SECRET_ACCESS_KEY= +export AWS_REGION=us-east-1 +export AWS_CA_BUNDLE=~/.extenddb/tls/cert.pem +aws dynamodb list-tables \ + --endpoint-url https://127.0.0.1:18443 \ + --region us-east-1 +``` + +Differences from the PostgreSQL backend: + +- **Replica set required:** Even single-node MongoDB must be configured as a replica set. +- **DynamoDB Streams:** Inline record writes with atomic sequence numbers. +- **GSI propagation:** Synchronous inline updates during data operations. +- **Concurrency model:** Optimistic versioning with retry on conflict (vs row-level locking in PostgreSQL). + ### Test Runner Script All tests should be run via `devtools/run-tests`, which handles credential provisioning, runtime configuration, and artifact collection. @@ -314,6 +409,54 @@ python3 devtools/run-external-tests --dry-run The external test runner parses Maven surefire XML reports as a fallback when `mvn -q` suppresses stdout summary lines. +ExtendDB supports running external test suites (Java/JUnit, Python/pytest, and others) against a running instance. Suites are registered in `external-suites.toml` at the project root (copy `external-suites.sample.toml` to create it; `--config PATH` selects another registry) and referenced by path, never copied into the repo. `--suite` can be repeated to run several named suites. + +Before running external suites directly, set the GSI propagation delay to 0. External suites expect synchronous GSI behavior (the service's propagation is usually under a millisecond); the async GSI path is tested separately by the ExtendDB-specific `test_gsi_async.py` suite. `run-tests` does this for you. + +```bash +./target/release/extenddb settings --config extenddb.toml set index_propagation_delay_ms 0 +``` + +Further options of `run-external-tests`: + +```bash +# Override the endpoint (default: $EXTENDDB_ENDPOINT or http://localhost:18443) +python3 devtools/run-external-tests --endpoint http://localhost:9000 + +# Generate a JSON report +python3 devtools/run-external-tests --report results.json +``` + +`--dry-run` shows what would execute without running anything; `--verbose` shows full test output. + +#### Registering a new suite + +Add a `[[suite]]` entry to `external-suites.toml`: + +```toml +[[suite]] +name = "My Test Suite" +path = "~/source/my-test-suite" +runner = "maven" # maven, gradle, pytest, or cargo +enabled = true + +[suite.env] +DDB_ENDPOINT = "${EXTENDDB_ENDPOINT}" +``` + +The `${EXTENDDB_ENDPOINT}` placeholder is replaced with the `--endpoint` value at runtime. + +Supported runners: `maven` (`mvn test`), `gradle` (`gradle test`), `pytest` (`python3 -m pytest`), `cargo` (`cargo test`). + +#### Prerequisites + +Each runner requires its tools to be installed. The runner checks prerequisites before executing and skips suites with missing tools: + +- **maven:** `java`, `mvn` +- **gradle:** `java`, `gradle` +- **pytest:** `python3`, `pytest` +- **cargo:** `cargo` + ### Rust Unit Tests ```bash diff --git a/docs/manuals/07-upgrade-manual.md b/docs/manuals/07-upgrade-manual.md index be2c5e4b1..d384e47fc 100755 --- a/docs/manuals/07-upgrade-manual.md +++ b/docs/manuals/07-upgrade-manual.md @@ -51,6 +51,8 @@ A backup that 0.1.14 or an earlier release took can restore without its global a The [general upgrade procedure](#general-upgrade-procedure) gives the sequence. The [version history](#version-history) records the catalog versions of 0.1.14 and earlier and what those binaries print, and [Behavior Changes by Release](#behavior-changes-by-release) what each release changes in behavior. +This page covers a server built from source ([General Upgrade Procedure](#general-upgrade-procedure)) and a deployment running the published container images ([Upgrading a container deployment](#upgrading-a-container-deployment)). For installing either, see [Install from source](../install-from-source.md), [Docker Compose with PostgreSQL](../local-dev-docker-compose.md) and [Development image](../dev-image.md). + ## How Catalog Upgrades Work ### The Migration System @@ -206,6 +208,8 @@ On PostgreSQL `migrate --yes` can also print: On PostgreSQL one `--lock-timeout` bounds every wait of a run together: the wait for another migrator's lock, the wait for running servers, and the wait for an earlier migrator's statements. Each wait gets the time the earlier ones left, and its line prints the seconds left. With `--lock-timeout 0` a run makes one attempt at each: it exits 6 at once when another migrator or a running server holds its key, or when an earlier migrator's statement is still running. +Exit 3 for a pending preview is the behaviour of a binary built from this tree. The published tags up to `0.1.14` print `Error: --yes is required to apply migrations. Pending: ...` and exit 1 instead; see [Upgrading a container deployment](#upgrading-a-container-deployment). + 5. **Verify** ```bash @@ -222,6 +226,201 @@ extenddb serve --config extenddb.toml SQLite deployments follow the same sequence, backing up the database files as [SQLite](#sqlite) describes. MongoDB deployments track their own catalog version, and a release states whether it changes; the Behavior Changes section below still applies to them. +## Upgrading a container deployment + +The published images carry the same binary as a source build, so the catalog rules above apply unchanged: `migrate` must run once per deployment before the new server starts, and an older binary refuses a newer catalog. What differs is where `migrate` runs and how the version is chosen: the version is the image tag, and the repository's Compose files run `migrate` for you in the `extenddb-bootstrap` service. That service runs the preview first (`extenddb migrate --config ...`, which takes no lock) and runs `migrate --yes` only when the preview exits 3, so an `up` on a current catalog exits 0 without taking the migration lock. A preview that exits with another status ends the service with that status, and the server does not start. + +Published tags are listed on Docker Hub for [`extenddb/extenddb-postgres`](https://hub.docker.com/r/extenddb/extenddb-postgres/tags), [`extenddb/extenddb-dev`](https://hub.docker.com/r/extenddb/extenddb-dev/tags) and [`extenddb/extenddb-mongodb`](https://hub.docker.com/r/extenddb/extenddb-mongodb/tags). `docker run --rm version` prints the catalog version an image expects. The newest published tag, `1.0.0`, reports `catalog migration 12` and the name of its backend. `0.1.15` and `1.0.0` carry the migration ledger this page describes, with migrations 1 to 12. `0.1.14`, the last tag before the ledger, reports `catalog 0.0.3 (postgres)`, `catalog 0.0.3 (sqlite)` and `catalog 0.0.2 (mongodb)`. The PostgreSQL tags `0.1.5` to `0.1.10` report `catalog 0.0.2 (postgres)`, and every `extenddb-dev` tag up to `0.1.14` reports `catalog 0.0.3 (sqlite)`. The commands and output below were run on the PostgreSQL stack upgraded from `0.1.14` (catalog 0.0.3) to `1.0.0` (catalog migration 12), so they show a volume initialised before the migration ledger being migrated. + +### Docker Compose (PostgreSQL) + +This is the stack started as described in [Docker Compose with PostgreSQL](../local-dev-docker-compose.md): the repository's `docker-compose.yml`, run from the directory that holds it, with the image chosen by `EXTENDDB_IMAGE`. The catalog lives in the `postgres` container's `postgres-data` volume; the config file and TLS material live in the `extenddb-state` volume. Neither volume is touched by changing the image tag, so an upgrade keeps the tables, items, users and access keys. + +Every `docker compose` command below needs the same `EXTENDDB_IMAGE` the stack was started with, until the step that changes it. Setting it on each command works; so does putting `EXTENDDB_IMAGE=extenddb/extenddb-postgres:0.1.14` in a `.env` file beside the Compose file, which Compose reads on every command, in which case the upgrade is one edit to that file. + +1. **Back up the catalog and data databases.** `pg_dump` runs inside the `postgres` container; the PostgreSQL superuser is `PG_ADMIN_USER` (default `postgres`) and the database names are the Compose defaults. + +```bash +docker compose exec -T postgres pg_dump -U postgres extenddb_catalog > catalog_backup_$(date +%Y%m%d).sql +docker compose exec -T postgres pg_dump -U postgres extenddb > data_backup_$(date +%Y%m%d).sql +``` + +A catalog at 0.0.3 holding one table dumped to 780 non-empty lines; the dump's `settings` rows include `catalog_version\t0.0.3`, which is how to check what a dump holds. + +2. **Change the tag, pull, and start.** Compose compares the image of every service against the running containers, recreates `extenddb-volume-init`, `extenddb-bootstrap` and `extenddb` from the new image (which stops the server), runs the two bootstrap services to completion and starts the server. The server is stopped before `extenddb-bootstrap` starts, so `migrate` runs with no server on the catalog. + +```bash +export EXTENDDB_IMAGE=extenddb/extenddb-postgres:1.0.0 +docker compose pull extenddb +docker compose up -d +``` + +``` + Container extenddb-postgres-dev-postgres-1 Running + Container extenddb-postgres-dev-extenddb-volume-init-1 Recreate + Container extenddb-postgres-dev-extenddb-volume-init-1 Recreated + Container extenddb-postgres-dev-extenddb-bootstrap-1 Recreate + Container extenddb-postgres-dev-extenddb-bootstrap-1 Recreated + Container extenddb-postgres-dev-extenddb-1 Recreate + Container extenddb-postgres-dev-extenddb-1 Recreated + Container extenddb-postgres-dev-extenddb-volume-init-1 Started + Container extenddb-postgres-dev-postgres-1 Healthy + Container extenddb-postgres-dev-extenddb-volume-init-1 Exited + Container extenddb-postgres-dev-extenddb-bootstrap-1 Started + Container extenddb-postgres-dev-extenddb-bootstrap-1 Exited + Container extenddb-postgres-dev-extenddb-1 Started +``` + +Compose also prints `Starting` and `Waiting` lines, left out above. + +3. **Read the bootstrap log.** `extenddb-bootstrap` finds the config file written by the first start in `/var/lib/extenddb/extenddb.toml`, runs the preview `extenddb migrate --config /var/lib/extenddb/extenddb.toml`, and when that exits 3 runs `extenddb migrate --config /var/lib/extenddb/extenddb.toml --yes --pg-user $PG_ADMIN_USER`, with `EXTENDDB_PG_PASSWORD` taken from `PG_ADMIN_PASSWORD`. On a first start, when the file does not exist, the same service runs `extenddb init` instead. + +```bash +docker compose logs extenddb-bootstrap +``` + +``` +bootstrap: existing config detected; running migrations +=== extenddb migrate === +Config: /var/lib/extenddb/extenddb.toml +Catalog: postgresql://extenddb_app:***@postgres:5432/extenddb_catalog (postgres) + +Stop every server that uses this catalog before applying: a server of a release before 0.1.15 is not detected while it runs. +The catalog has no migration ledger (a release before 0.1.15 created it); this binary carries migrations 1 to 12. +Pending: + 1 baseline (catalog, breaking): create the catalog schema, or bring a released catalog to it + 1 baseline (data, breaking): create the catalog schema, or bring a released catalog to it + ... + 12 unique_access_key_ids (catalog, additive): make every access key ID unique, which the MongoDB catalog did not enforce +Migration 2 rewrites no stored policy. + +Nothing was changed; back up both PostgreSQL databases, the catalog database extenddb_catalog and the data database extenddb, then run again with --yes to apply (exit status 3: migrations pending). +=== extenddb migrate === +Config: /var/lib/extenddb/extenddb.toml +Catalog: postgresql://extenddb_app:***@postgres:5432/extenddb_catalog (postgres) + +--- Taking the migration lock (waiting up to 60 s for a server or another migration)... + Applied 1 baseline in extenddb_catalog + Applied 1 baseline in extenddb + Applied 2 resource_tag_condition_keys in extenddb_catalog + ... + Applied 11 attribute_name_escape in extenddb + Recorded 12 unique_access_key_ids in extenddb_catalog as not applicable + +=== extenddb migrate complete === +Catalog: no ledger -> migration 12 +``` + +The log is shortened to its first and last migration lines. On a volume whose catalog already matches the new image, the preview prints `Up to date: the catalog is at migration 12, the latest this binary carries. No migrations needed.` and the service exits 0 without running `migrate --yes`. The `pgvector` notice described under [Catalog 0.0.3](#catalog-003) appears in this log on the Compose stack, because the `postgres` image carries no `vector` extension. + +4. **Check the server.** `docker compose ps -a` shows `extenddb-bootstrap` as `Exited (0)` and `extenddb` as `(healthy)` after 10 to 20 seconds, both on the new image. The first lines of the server's log after the banner name the version and catalog it started with: + +```bash +docker compose logs extenddb +``` + +``` +extenddb 1.0.0 (catalog migration 12) starting on 0.0.0.0:18443 + storage: postgres (postgresql://extenddb_app:***@postgres:5432/extenddb_catalog) + backup store: none ([backup.store] is absent); CreateBackup writes in-catalog backups +``` + +A table created and an item written under `0.1.14` were listed and read back unchanged through the `1.0.0` server with the same access key; `select value from settings where key = 'catalog_version'` on the catalog database returned `12`, the catalog database's `extenddb_migrations` ledger listed migrations 1 to 12 and the data database's ledger 1, 4, 7, 8 and 11. The `schema_history` table of the older release keeps its three rows and is not read. + +#### Running migrate as a one-off step + +To see or apply the migration separately from starting the server, stop the server and run the bootstrap service on its own. It runs the preview and then, when the preview exits 3, the same `migrate --yes`, and exits with the exit status of `migrate`; `--rm` removes the one-off container. + +```bash +docker compose stop extenddb +EXTENDDB_IMAGE=extenddb/extenddb-postgres:1.0.0 docker compose run --rm extenddb-bootstrap +echo $? +``` + +On a catalog at 0.0.3 this printed the plan, applied migrations 1 to 12, printed `Catalog: no ledger -> migration 12` and exited 0. To preview without applying, override the entrypoint and leave `--yes` off; a pending migration prints the plan and exits 3: + +```bash +EXTENDDB_IMAGE=extenddb/extenddb-postgres:1.0.0 docker compose run --rm --entrypoint extenddb \ + extenddb-bootstrap migrate --config /var/lib/extenddb/extenddb.toml --pg-user postgres +``` + +``` +Nothing was changed; back up both PostgreSQL databases, the catalog database extenddb_catalog and the data database extenddb, then run again with --yes to apply (exit status 3: migrations pending). +``` + +The Compose files of this release upgrade to `0.1.15` or later only. The `migrate` of a tag up to `0.1.14` exits 1 on a pending catalog, so with such a tag as the target the bootstrap service exits 1 and the server is not started. On a catalog that tag is already at, its preview exits 0 (`Everything is up to date (catalog version 0.0.3). No migrations needed.`) and the stack starts. + +`docker compose run --rm extenddb-bootstrap` does not stop a running server first: run while the `1.0.0` server was up on a current catalog, it printed `Up to date: the catalog is at migration 12, the latest this binary carries. No migrations needed.` and exited 0. Stop the server before a run that applies a migration, as step 1 of the general procedure does and as `docker compose up -d` does. After the one-off run, `docker compose up -d` recreates the server from the new image; its own `extenddb-bootstrap` run then reports nothing pending. + +#### What a downgrade shows + +Pointing `EXTENDDB_IMAGE` at the older tag and running `docker compose up -d` fails at the Compose level. The older image's `extenddb-bootstrap` runs its preview against the newer catalog, reads `Current version: 12`, and exits 1; the catalog is not changed. Compose stops there: `docker compose up -d` prints `service "extenddb-bootstrap" didn't complete successfully: exit 1` and exits 1, `docker compose ps -a` shows `extenddb-bootstrap` as `Exited (1)` and `extenddb` as `Created` on the older image, the server never starts, and the port answers nothing. The refusal is in the bootstrap's log, shown without its table key and resource-tag check lines: + +```bash +docker compose logs extenddb-bootstrap +``` + +``` +bootstrap: existing config detected; running migrations +=== extenddb migrate === +Config: /var/lib/extenddb/extenddb.toml + +--- Loading defaults from /var/lib/extenddb/extenddb.toml +--- Checking current catalog version... + Current version: 12 +--- Checking data migrations... + Data migrations up to date. +Error: --yes is required to apply migrations. Pending: catalog 12 -> 0.0.3; record the resource-tag migration marker. +``` + +Setting `EXTENDDB_IMAGE` back to the newer tag and running `docker compose up -d` brought the server back with its data: the table and item written under `0.1.14` were listed and read back. To run the older version on the data written before the upgrade, follow [Rollback Procedure](#rollback-procedure) against the `postgres` container (`docker compose exec -T postgres psql -U postgres -d postgres -c ...` and `docker compose exec -T postgres psql -U postgres -d extenddb_catalog < catalog_backup_YYYYMMDD.sql`), then start the older image. + +### Docker Compose (MongoDB) + +`docker-compose.mongodb.yml` has the same `extenddb-bootstrap` service; its image variable is `EXTENDDB_MONGODB_IMAGE` and its `migrate` takes no admin flags. The upgrade is the same three commands with `-f docker-compose.mongodb.yml` and the MongoDB variable. Upgrading from `extenddb/extenddb-mongodb:0.1.14` to `1.0.0` applied migrations 1 to 12 in the bootstrap log (`Catalog: no ledger -> migration 12`; on MongoDB migrations 3, 4, 7, 8, 9 and 11 are recorded as not applicable) and the server started with `extenddb 1.0.0 (catalog migration 12) starting on 0.0.0.0:18443`. The table and item written under `0.1.14` were still there, but the access key created under `0.1.14` answered `UnrecognizedClientException` through the `1.0.0` server, and `manage list-accounts` listed no account. The account document that `init` writes on MongoDB has no `account_id` field, which this release's credential lookup and account listing read ([#643](https://github.com/ExtendDB/extenddb/issues/643)). Until that is fixed, set the field on the account documents after the upgrade, then check `manage list-accounts`: + +```bash +docker compose -f docker-compose.mongodb.yml exec -T mongodb mongosh --quiet extenddb_catalog \ + --eval 'db.accounts.find({account_id: {$exists: false}}).forEach(a => db.accounts.updateOne({_id: a._id}, {$set: {account_id: a._id}}))' +``` + +With the field set, `manage list-accounts` listed the account and the same `0.1.14` access key listed and read the table through the `1.0.0` server. A key that the server refused less than 5 seconds earlier stays refused until that time passes (`[auth.cache] negative_ttl_seconds`). The MongoDB container's notes are in [docker/README-mongodb.md](https://github.com/ExtendDB/extenddb/blob/main/docker/README-mongodb.md). + +### The development image + +`extenddb/extenddb-dev` (see [Development image](../dev-image.md)) has no bootstrap service and no config file: `serve` creates the SQLite database in `/var/lib/extenddb` on first start and opens it on later starts. Upgrading is replacing the container with one from the new tag on the same volume. With `docker run`: + +```bash +docker pull extenddb/extenddb-dev:1.0.0 +docker rm -f +docker run -d -p 127.0.0.1:18080:18080 -v extenddb:/var/lib/extenddb extenddb/extenddb-dev:1.0.0 +``` + +With the repository's `docker-compose.dev.yml`, where the image is `EXTENDDB_DEV_IMAGE`: + +```bash +EXTENDDB_DEV_IMAGE=extenddb/extenddb-dev:1.0.0 docker compose -f docker-compose.dev.yml pull extenddb-dev +EXTENDDB_DEV_IMAGE=extenddb/extenddb-dev:1.0.0 docker compose -f docker-compose.dev.yml up -d extenddb-dev +``` + +Both were run from `0.1.14` to `1.0.0`, with a table and an item written on the first version. The second start copies the database file aside (to `extenddb.sqlite.pre-migration--to--