datalevin

Max 2026-06-26T15:41:52.600589Z

What https://www.postgresql.org/docs/current/transaction-iso.html does datalevin provide for queries in transactions? (another book q)

Huahai 2026-06-27T00:53:33.928979Z

serializable

Huahai 2026-06-27T00:54:16.507479Z

added in book

Max 2026-06-27T00:55:07.335539Z

Does starting a transaction lock out other transactions until it completes? Or are transactions (via the callback or macro) basically just datomic tx fns with a different syntax?

Huahai 2026-06-27T00:55:47.556109Z

it does

Huahai 2026-06-27T00:56:27.705759Z

not sure what the second question is about.

Huahai 2026-06-27T00:57:11.323999Z

transaction is wrapped in with-transaction internally. so it is essentially a LMDB transaction, which is serialized

Max 2026-06-27T00:58:13.223549Z

I see, so txns via callbacks basically work the same way as txn fns, there's no performance trade off between them?

Huahai 2026-06-27T00:59:40.637159Z

no difference, there is only one type of write transaction. whatever form, eventually, they becomes a LMDB txn

Max 2026-06-27T01:00:23.443809Z

So basically the difference is just syntax

Huahai 2026-06-27T01:00:59.066619Z

I don't think datomic has with-transaction, the semantics are quite different.

Huahai 2026-06-27T01:01:18.366159Z

datomic is immutable, the idea of txn there is different from usual sense

Huahai 2026-06-27T01:01:46.193499Z

so I won't compare datalevin with datomic

Max 2026-06-27T01:02:36.366089Z

Datomic only has transaction fns, but but the approach for serializing transactions seems to be the same: at the start of a transaction, writes are locked, and they're unlocked once the transaction succeeds

Max 2026-06-27T01:02:42.599349Z

so they're also fully serialized

Huahai 2026-06-27T01:03:39.131209Z

yes, in that sense, it is the same, but within the transaction, the read/write are handled quite differently

Max 2026-06-27T01:03:49.385199Z

How so?

Huahai 2026-06-27T01:04:17.576349Z

in datalevin, inside a transaction, later reads can read prior writes

Huahai 2026-06-27T01:04:38.067919Z

in datomic, there's no prior or later stages

Max 2026-06-27T01:04:42.322889Z

That's true

Max 2026-06-27T01:05:27.073039Z

You can emulate it with speculative transactions, but yes that part of the model is different

Huahai 2026-06-27T01:05:32.170209Z

datomic behavior would be considered surprising for some users

Max 2026-06-27T01:05:37.124499Z

Right

Max 2026-06-27T01:06:20.600669Z

In datalevin, do transaction fns work the same way they do in datomic? I.e. there's no way to read prior writes, they just return tx data?

Huahai 2026-06-27T01:06:52.129949Z

you can read your writes inside the txn

Max 2026-06-27T01:08:18.383819Z

Right, but you can't write in a tx fn (udf-based, interned, or inline), you just return tx-data

Huahai 2026-06-27T01:08:20.499689Z

so you can write your txn fn in a normal stateful way

Max 2026-06-27T01:08:27.877149Z

oooh interesting

Max 2026-06-27T01:08:48.209679Z

so your tx-fn could return nil and statefully call transact!

Huahai 2026-06-27T01:10:23.197669Z

what you do in a custom tx function is up to you, it may have side effect, datalevin doesn't care. it only cares about db read/write. you can do whatever else. like some people do in sql

Max 2026-06-27T01:10:50.351359Z

Got it, so there's not the same contract where tx-fns have to return tx-data

Max 2026-06-27T01:10:51.395059Z

The "different syntax" thing was in reference to how in datalevin, doing a transaction via a transaction fn vs via with-transaction does the exact same thing under the hood (as far as I understand), so there's no performance tradeoffs between the different methods of doing transactions. Is that correct?

Huahai 2026-06-27T01:11:12.496289Z

correct

Huahai 2026-06-27T01:11:45.775459Z

a nested txn inside a txn will be using the outer txn, no new txn is created

Huahai 2026-06-27T01:12:03.428419Z

so whatever you do ,there's only one txn at a time

Huahai 2026-06-27T01:16:10.425989Z

BTW, do you mind to be added to the acknowledgment as reviewer? I would need your full name for that 🙂

Max 2026-06-27T01:16:21.631319Z

For sure! Max Rothman

Max 2026-06-27T01:16:38.392329Z

It might be a good idea to have a chart or something contrasting the different txn methods so readers know what's the same and different between them

Huahai 2026-06-27T01:25:02.210829Z

Will do