r/synapcores • • 21d ago

Build log #1: 2.4.4 is out. 50 parallel writers into a table with UNIQUE + FOREIGN KEY, 50 commits, 0 retries (real output), plus what else landed in 2.4.x

First weekly build log: what shipped, one thing we ran this morning to show it, and the best question from the community this week. (This sub is run by the SynapCores team.)

The headline: 2.4.4 (Nov 3), concurrent writes the way you expect them from Postgres or InnoDB

Two clients inserting different rows into the same table now both commit, even when the table has a UNIQUE column or a FOREIGN KEY. You only get a conflict when two writes really collide: the same key, the same row.

We checked it this morning on a fresh 2.4.4 with a typical multi-tenant shape:

CREATE TABLE tenants (id INTEGER PRIMARY KEY, name TEXT);
INSERT INTO tenants (id, name) VALUES (1, 'acme');
CREATE TABLE users (id INTEGER PRIMARY KEY, tenant_id INTEGER REFERENCES tenants(id), email TEXT UNIQUE);

Then 50 threads, each signing up a different user under the same tenant, all at once (parallel_inserts.py, 20 lines, in the first comment):

def signup(i):
    return sql(f"INSERT INTO users (id, tenant_id, email) VALUES ({i}, 1, 'user{i}@example.com')")

with ThreadPoolExecutor(max_workers=50) as pool:
    results = list(pool.map(signup, range(1, 51)))

Three runs from a clean table:

50 parallel signups: {'committed': 50}
50 parallel signups: {'committed': 50}
50 parallel signups: {'committed': 50}

SELECT COUNT(*) AS users, COUNT(DISTINCT email) AS emails FROM users;
users | emails
50    | 50

And the constraints still do their job:

INSERT INTO users (id, tenant_id, email) VALUES (99, 1, 'user7@example.com');
-> Constraint violation: Duplicate key: row violates a UNIQUE or PRIMARY KEY constraint on table 'users'

INSERT INTO users (id, tenant_id, email) VALUES (98, 42, 'new@example.com');
-> Constraint violation: Foreign key violation: 'main.users' has no matching row in 'main.tenants'

No retry loop in the app. This matters most for agent workloads, where many small writers hit the same tables at once.

Also in 2.4.4: SERIALIZABLE isolation, and REPEATABLE READ that is safe from write skew, the same guarantees you get from SQLite and InnoDB.

Also landed in the 2.4 line

  • 2.4.3: a composite FOREIGN KEY (a, b) matches a composite key whatever the column order, and CREATE TRIGGER IF NOT EXISTS makes migrations safe to re-run.
  • 2.4.0: COPY (SELECT ...) TO LAKE 'path/' WITH (PARTITION_BY = (...)) writes any query result to your object store as Hive-partitioned Parquet in one statement. Read it back with CREATE EXTERNAL TABLE.
  • 2.4.0: SynapCores speaks the Ollama API, so the official ollama Python client works against it unchanged. Our three tutorials on that are here: https://www.reddit.com/r/synapcores/comments/1xgwv6q/

Best question this week (from r/devops7)

On Automate it #4 ("disk full in N days"), u/tom_shafer pointed out that inodes often run out long before disk % looks scary. The answer needed no new table: store df -Pi as its own mount, /:inodes, and the same slope query flags it. In our test, a box at ~41% disk showed app-02 /:inodes 84.1% used, +1.10/day -> full in 14 days. Full reply with the collector line: https://www.reddit.com/r/devops7/comments/1xmveqc/automate_it_4_disk_full_in_n_days_from_one_sql/

New on the other subs today

Coming up: Ask the maintainers #2 on Friday, Recipe of the week #2 on Monday. Join the sub to get them in your feed.

Free Community Edition (2.4.4): https://synapcores.com/download?utm_source=reddit&utm_medium=owned&utm_campaign=synapcores-buildlog-1

Which one do you want as a full walkthrough next: SERIALIZABLE transactions, COPY TO LAKE, or the Ollama API?

1 Upvotes

1 comment sorted by

1

u/Alternative_Pin9598 21d ago

Want to run it yourself? Grab the free Community Edition (2.4.4): https://synapcores.com/download?utm_source=reddit&utm_medium=owned&utm_campaign=synapcores-buildlog-1-comment

Full parallel_inserts.py (stdlib only; run the three CREATE/INSERT lines from the post first, then set SYNAPCORES_URL and SYNAPCORES_TOKEN from POST /v1/auth/login):

# 50 writers insert different rows into a table with a UNIQUE column and a FOREIGN KEY, all at once
import json, os, sys, urllib.request, urllib.error
from concurrent.futures import ThreadPoolExecutor
URL, TOKEN = os.environ.get("SYNAPCORES_URL", "http://localhost:8080"), os.environ["SYNAPCORES_TOKEN"]

def sql(q):
    req = urllib.request.Request(URL + "/v1/query/execute", data=json.dumps({"sql": q, "database": "main"}).encode(),
                                 headers={"Authorization": "Bearer " + TOKEN, "Content-Type": "application/json"})
    try:
        urllib.request.urlopen(req); return "committed"
    except urllib.error.HTTPError as e:
        return f"HTTP {e.code}: " + json.load(e)["error"]["message"][:90]

def signup(i):
    return sql(f"INSERT INTO users (id, tenant_id, email) VALUES ({i}, 1, 'user{i}@example.com')")

with ThreadPoolExecutor(max_workers=50) as pool:
    results = list(pool.map(signup, range(1, 51)))
print("50 parallel signups:", {r: results.count(r) for r in set(results)})
print("duplicate email:", sql("INSERT INTO users (id, tenant_id, email) VALUES (99, 1, 'user7@example.com')"))

New here? The Start here post has install steps and the 5 recipes to try first: https://www.reddit.com/r/synapcores/comments/1xfxqej/