influxdb/iox_catalog
Marco Neumann 5de4d6203f
refactor: catalog transaction (#3660)
* refactor: catalog Unit of Work (= transaction)

Setup an inteface to handle Units of Work within our catalog. Previously
both the Postgres and the in-mem backend used "mini-transactions on
demand". Now the caller has a clear way to establish boundaries and
gets read and write isolation. A single `Arc<dyn Catalog>` can create as
many `Box<dyn UnitOfWork>` as you like, but note that depending on the
backend you may not scale infinitely (postgres will likely impose
certain limits and the in-mem backend limits concurrency to 1 to keep
things simple).

* docs: improve wording

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

* refactor: rename Unit of Work to Transaction

* test: improve `test_txn_isolation`

* feat: clearify transaction drop semantics

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-02-08 13:38:33 +00:00
..
migrations feat: allow IOx catalog to setup itself (no SQLx CLI required) (#3584) 2022-01-31 15:07:38 +00:00
src refactor: catalog transaction (#3660) 2022-02-08 13:38:33 +00:00
Cargo.toml refactor: catalog transaction (#3660) 2022-02-08 13:38:33 +00:00
README.md feat: allow IOx catalog to setup itself (no SQLx CLI required) (#3584) 2022-01-31 15:07:38 +00:00
build.rs feat: allow IOx catalog to setup itself (no SQLx CLI required) (#3584) 2022-01-31 15:07:38 +00:00

README.md

IOx Catalog

This crate contains the code for the IOx Catalog. This includes the definitions of namespaces, their tables, the columns of those tables and their types, what Parquet files are in object storage and delete tombstones. There's also some configuration information that the overal distributed system uses for operation.

To run this crate's tests you'll need Postgres installed and running locally. You'll also need to set the DATABASE_URL environment variable so that sqlx will be able to connect to your local DB. For example with user and password filled in:

DATABASE_URL=postgres://<postgres user>:<postgres password>@localhost/iox_shared

You'll then need to create the database. You can do this via the sqlx command line.

cargo install sqlx-cli
sqlx database create

This will set up the database based on the files in ./migrations in this crate. SQLx also creates a table to keep track of which migrations have been run.

Tests

To run the Postgres integration tests, ensure the above setup is complete first.

  • Set DATABASE_URL=<dsn> env (see above)
  • Set TEST_INTEGRATION=1
  • Run cargo test

CAUTION: existing data in the database is dropped when tests are run