Skip to content

Commit

Permalink
Copy wiki documents into the Guides
Browse files Browse the repository at this point in the history
  • Loading branch information
drteeth committed Dec 1, 2024
1 parent 253ae6e commit a8c0334
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
15 changes: 15 additions & 0 deletions guides/Architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### PostgreSQL usage

EventStore creates multiple connections to the Postres database:

- a pooled connection, that you configure via `config/config.exs`, used for most database operations (e.g. reading/appending events);
- a connection used to listen for event notifications (using Postgres' `LISTEN` / `NOTIFY`);
- and another connection for subscription [advisory locks](https://www.postgresql.org/docs/current/static/explicit-locking.html#ADVISORY-LOCKS).

If you configure EventStore to use a `pool_size` of 10, then you will have 12 Postgres database connections in total.

The pooled connection uses `:exp` back-off. However the other connections use `:stop` back-off so that the connection process terminates when the database connection is broken. These connections are monitored by another process and will be restarted.

#### Why are these connections stopped on error?

Related processes need to be notified when the connection exits or is restarted. The [postgrex](https://hexdocs.pm/postgrex/) library doesn't provide a way of being notified when the connection terminates. As an example, EventStore uses [Postgres' advisory locks](https://www.postgresql.org/docs/current/static/explicit-locking.html#ADVISORY-LOCKS) to guarantee only one instance of a subscription runs, regardless of how many nodes are running (or whether they are clustered). These advisory locks are tied to a database connection and are released when the connection terminates. When this happens, EventStore attempts to reacquire the locks. The `EventStore.MonitoredServer` module provides this process monitoring and `after_exit` and `after_restart` callback functions.
34 changes: 34 additions & 0 deletions guides/FAQ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Frequently asked questions

- [What version of PostgreSQL is supported?](#what-version-of-postgresql-is-supported)
- [Which PostgreSQL hosting provider is supported?](#which-postgresql-hosting-provider-is-supported)

---

### What version of PostgreSQL is supported?

PostgreSQL v9.5 or later.

---

### Which PostgreSQL hosting provider is supported?

You can verify a potential hosting provider by running the EventStore test suite against an instance of the hosted PostgreSQL database. If all tests pass, then you should be fine.

To run the test suite you must first clone this GitHub repository:

```console
git clone https://github.com/commanded/eventstore.git
cd eventstore
mix deps.get
```

Then configure your database connection settings for the test environment, in `config/test.exs`.

Once configured, you can create the test database and run the tests:

```console
MIX_ENV=test mix do event_store.create, event_store.init
mix test
```

2 changes: 2 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ defmodule EventStore.Mixfile do
"guides/Subscriptions.md",
"guides/Cluster.md",
"guides/Event Serialization.md",
"guides/Architecture.md",
"guides/FAQ.md",
"guides/Upgrades.md",
"guides/upgrades/0.17-1.0.md": [
filename: "0.17-1.0",
Expand Down

0 comments on commit a8c0334

Please sign in to comment.