HackerTrans
TopNewTrendsCommentsPastAskShowJobs

imor80

no profile record

Submissions

Show HN: Pg_replicate – Build Postgres replication applications in Rust

github.com
216 points·by imor80·2 năm trước·28 comments

Postgres Roles and Privileges

supabase.com
12 points·by imor80·2 năm trước·1 comments

comments

imor80
·10 tháng trước·discuss
There are two levels on which this argument feels weak:

* The author is confusing memory safety with other kinds of safety. This is evident from the fact that they say you can write unsafe code in GC languages like python and javascript. unsafe != memory unsafe. Rust only gives you memory safety, it won't magically fix all your bugs.

* The slippery slope trick. I've seen this so often, people say because Rust has unsafe keyword it's the same as c/c++. The reason it's not is because in c/c++ you don't have any idea where to look for undefined behaviour. In Rust at least the code points you to look at the unsafe blocks. The difference is of degree which for practial purposes makes a huge difference.
imor80
·năm ngoái·discuss
Interested to know how it compares with PgDog: https://pgdog.dev/
imor80
·2 năm trước·discuss
A lot of what you say is explained in detail in Martin Kleppmann's article[0]. As you said, there's no guarantee about when the lock will expire. The proper solution for this is a fencing token. The idea is similar to how people have used optimistic locking when updating data in a db to avoid two users overwriting other's work.

[0]: https://martin.kleppmann.com/2016/02/08/how-to-do-distribute...
imor80
·2 năm trước·discuss
Not yet, but it is planned for the future. We'd need to pick one of the two options you suggested.
imor80
·2 năm trước·discuss
These days, for writing extensions/FFI pgrx[0] is the best crate.

[0] https://github.com/pgcentralfoundation/pgrx
imor80
·2 năm trước·discuss
Please do share your experience using pg_replicate as feedback once you integrate with windmill.
imor80
·2 năm trước·discuss
pg-bifrost looks solid.

> Have you thought about / have solved sharding consumption across multiple slots / multi consumers to increase throughput?

Not yet, there has been not performance yet, as the project is still quite young.
imor80
·2 năm trước·discuss
Thanks for trying out, I'll update the code and/or the README to fix this.
imor80
·2 năm trước·discuss
Agree, Rust and Postgres and a perfect match. It feels so much more productive to write Postgres tooling in Rust. E.g. we already have extensions like pg_graphql[0], pg_jsonschema[1] and wrappers[2] which use pgrx. We don't have plrust on the platform yet though.

Full disclosure: I'm a Rust Engieer at Supabase.

[0] https://github.com/supabase/pg_graphql [1] https://github.com/supabase/pg_jsonschema [2] https://github.com/supabase/wrappers
imor80
·2 năm trước·discuss
Yes, logical replication complements very nicely the normal way of interacting with the database via queries. This inverted flow makes those apps possible which were hard/impossible to build with just queries.
imor80
·2 năm trước·discuss
> I’m curious in your experience how many clients can run pg_replicate at once?

I'd expect more clients to put more pressure on the resource usage on the db. But it's not clear whether the relationship between number of clients and resource usage is linear, quadratic or something else since I haven't done benchmarking yet.

> The idea of scaling an application by tailing logs from a database sounds very interesting to me, and I’m curious if you’ve explored this at all. There’s of course things like Kafka (and then things like Debezium), but it’s hard to beat direct!

It doesn't exist yet, but I was thinking of creating a sink which exposes Postgres WAL via websockets. This way the number of clients might scale much better.
imor80
·2 năm trước·discuss
Hey HN,

For the past few months, as part of my job at Supabase, I have been working on pg_replicate. pg_replicate lets you very easily build applications which can copy data (full table copies and cdc) from Postgres to any other data system. Around six months back I was figuring out what can be built by tailing Postgres' WAL. pg_replicate grew organically out of that effort. Many similar tools, like Debezium, exist already which do a great job, but pg_replicate is much simpler and focussed only on Postgres. Rust was used in the project because I am most comfortable with it. pg_replicate abstracts over the Postgres logical replication protocol[0] and lets you work with higher level concepts. There are three main concepts to understand pg_replicate: source, sink and pipeline.

1/ A source is a Postgres db from which data is to be copied. 2/ A sink is a data system into which data will be copied. 3/ A pipeline connects a source to a sink.

Currently pg_replicate supports BigQuery, DuckDb local file and, MotherDuck as sinks. More sinks will be added in future. To support a new data system, you just need to implement the BatchSink trait (older Sink trait will be deprecated soon).

pg_replicate is still under heavy development and is a little thin on documentation. Performance is another area which hasn't received much attention. We are releasing this to get feedback from the community and are still evaluating how (or if) we can integrate it with the Supabase platform. Comments and feedback are welcome.

[0] Postgres logical replication protocol: [https://www.postgresql.org/docs/current/protocol-logical-rep...)
imor80
·2 năm trước·discuss
I'd have definitely liked if the demo video was at least 1080p.
imor80
·2 năm trước·discuss
A follow along, tutorial style, guide to understanding how roles and privileges work in Postgres.
imor80
·2 năm trước·discuss
Copy and Clone traits have different semantics. Copy is only for bitwise (and cheap) copies. Clone is for explicit, potentially expensive copies. Also what entails cloning differs from type to type. String, for example, needs to duplicate the pointed to string buffer in the heap, while Arc only increments a reference count.