-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters