do folks here have guidance on implementing application level retry for transact so it works with an HA setup?
It’s not datomic specific, but you can easily use fusebox for this https://github.com/potetm/fusebox?tab=readme-ov-file#retry
How would that work with the following statement in https://docs.datomic.com/operation/deployment.html#peer-failover: > Not all transactions are idempotent, and transactions may have succeeded, even if the communication back to the peer failed. It seems that relying on application logic that uses return value of transact isn't enough to know whether something succeeded or not, but one has to use datomic/sync, although I'm not sure how
If a transaction might have failed, d/transact will throw. If your transaction is idempotent, you can just retry on exception.
If the transaction isn't idempotent, you can either make a transaction function that makes it idempotent, or you can get the latest db on the client-side and recalculate your transaction.
d/sync is used for when two different nodes are interacting and need to be sync'd to some version of the db. I don't think it's helpful here.
What are you all doing for working with your databases in production? Are there any good utilities out there to be aware of? For viewing the data, the Datomic Console is perfect: https://blog.datomic.com/2013/10/datomic-console.html. I can run this on my prod server, set it up behind some password protection, and I'm good to go for examining my DB. But for making changes (retracting accidental transactions, fixing customer data in emergency circumstances), I'm scratching my head for the best approach. I can imagine two options: - Provisioning a port with an nREPL connection to my application so I can jack in to the application and invoke database commands just like during local development. The most flexible option, but comes with obvious risks. You can secure that port behind some kind of auth mechanism, but it still introduces a direct line into the heart of your whole application. - Running the REST server, putting that behind an auth mechanism, and sending transactions over HTTP: https://docs.datomic.com/reference/rest.html. It is deprecated, but it strikes me as ... easier? Less flexible than a full REPL session, but with an interface and the opportunity to log requests.
Peer server
I'm surprised you are having good luck with console, because I have not. Once you scratch the surface of its abilities I run into all sorts of problems.
e.g. its query parsing
these are things I have seen:
• command to start an instance inside your vpc that can start a peer process with a remote repl with whatever classpath you want. Tunnel with ssh • a web-based admin application, with or without a generic query textarea. Buttons and pages and stuff for what you need. (This is really great for adding domain-specific queries, views and ops) • "backoffice" rest endpoints with handers that do what you want. Ad-hoc is disallowed, you must write a handler when you want to do something new. (I see this in regulated environments where no one is allowed open connections to production) • Run a peer-server, ssh-tunnel the client connection from a local repl with a client. Works really well for ad-hoc querying and manual tx fixups, but a drag if your app uses the peer api because a lot of code can't be shared.
I haven't seen it, but leaning into datafy/nav via morse may be cool too. Include operation thunks on datafy maps, and you have a very object-graph-like experience without the overhead of full webapp (html, rest handlers, http verbs, etc)
I usually deploy an administrative endpoint that is tuned for the particular scenario
For completness: with Datomic Cloud, this is not an issue since you can start a remote cloud client in your REPL.
The ability to visually navigate my data and click around inside of references is huge for me, and the console shines at this out of the box. Datafy/nav would be cool to investigate though if it can arbitrarily navigate around such things in a console-like way
The console can be a bit annoying when you try to write a query that would work in your application, but doesn't work in the console. I can live with it 😅
SSH tunnels into a peer process I think will be a good starting point, maybe with bespoke admin endpoints sprouting up as time goes on and common production data operations or needs become obvious
FWIW, I find biting the bullet and writing a web-based admin seems to pay dividends in the end, especially if non-devs are involved in the application's care and feeding
Indeed they will be
Having me on call to be the code monkey for this kind of stuff will get increasingly annoying over time
I don't suppose there's an example you're aware of out there for a Datomic-specific web admin interface? Something to reference or start with?
nothing I can show you, but there's nothing special about datomic
if anything it reduces the friction immensely--you can grab any web framework, doesn't need an orm
don't worry about perf, don't worry about frontend js/SPA. Use a big box css framework, out of box ring middleware, a routing library, render hiccup, sprinkle in some some htmx if you really don't want to reload the page
We've done just that: written an Admin UI using HTMX around datomic. Cheap, effective.
(but devs still tend to use the Datomic Cloud client from the REPL for complex stuff)
Retool could be an interesting option there: https://retool.com I've had a lot of success with Retool for SQL-based apps, maybe I'll give it a try.
@cch1 we're already building the app in HTMX! So we're pros at Datomic + HTTP forms + HTMX already 😆 It's been a fabulous combination. So much faster to build an application than anything else I've ever used.
I think if @dustingetz were here, he would probably mention electric as a candidate. More ambitious than a simple HTMX server, but a much higher ceiling. The demo is has a really powerful example of navigating Datomic.
We too are finding htmx (actually, unpoly) to be very effective for the html-based internal admin tooling.
i have been summoned, here is the https://electric.hyperfiddle.net/dustingetz.object-browser-demo3!ObjectBrowserDemo3/(dustingetz.object-browser-demo3!clojure-all-ns), we're actively developing it, we have not yet released. Click around! There's a datomic example. DM if you want to try it
and yes HTMX is much lighter than Electric for low ceiling apps, you should use it if you can