Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docker/dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,12 @@ services:
dockerfile: docker/universal/Dockerfile
target: engine-full
args:
BUILD_FRONTEND: 'true'
BUILD_FRONTEND: 'false'
platform: linux/amd64
restart: unless-stopped
environment:
# - RUST_LOG=debug
- RUST_BACKTRACE=1
- RUST_LOG_ANSI_COLOR=1
- RIVET_OTEL_ENABLED=1
- RIVET_OTEL_SAMPLER_RATIO=1
Expand Down
3 changes: 3 additions & 0 deletions docker/dev/rivet-engine/config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"postgres": {
"url": "postgresql://postgres:postgres@postgres:5432/rivet_engine"
},
"memory": {
"channel": "default"
},
"cache": {
"driver": "in_memory"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/common/cache/build/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub enum Error {
#[error("pools: {0}")]
Pools(#[from] rivet_pools::Error),

#[error("getter: {0}")]
#[error("cache getter: {0}")]
Getter(anyhow::Error),

#[error("serde decode: {0}")]
Expand Down
24 changes: 18 additions & 6 deletions packages/common/universaldb/src/driver/postgres/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ impl PostgresDatabaseDriver {
.await
.context("failed to create btree_gist extension")?;

conn.execute(
"CREATE SEQUENCE global_version_seq START WITH 1 INCREMENT BY 1 MINVALUE 1",
&[],
)
.await
.context("failed to create global version sequence")?;

// Create the KV table if it doesn't exist
conn.execute(
"CREATE TABLE IF NOT EXISTS kv (
Expand Down Expand Up @@ -96,14 +103,19 @@ impl PostgresDatabaseDriver {
"CREATE UNLOGGED TABLE IF NOT EXISTS conflict_ranges (
range_data BYTEARANGE NOT NULL,
conflict_type range_type NOT NULL,
txn_id BIGINT NOT NULL DEFAULT txid_current(),

-- This constraint prevents read-write conflicts ONLY between different transactions
-- Same transaction can have any combination of read/write overlaps
start_version BIGINT NOT NULL,
commit_version BIGINT NOT NULL,
ts timestamp NOT NULL DEFAULT now(),

EXCLUDE USING gist (
range_data WITH &&,
-- Conflict if byte range overlaps...
range_data WITH &&,
-- And f conflict types are different...
conflict_type WITH <>,
txn_id WITH <>
-- And f the txn versions overlap...
int8range(start_version, commit_version, '[]') WITH &&,
-- But not if the start_version is the same (from the same txn)
start_version WITH <>
)
)",
&[],
Expand Down
Loading
Loading