Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Would writing some of the data to the db while writing some of the data directly to kafka make it less consistent during faults?

Yes, this kind of "dual writes" are prone to inconsistencies. If either the DB transaction rolls back, or the Kafka write fails, you'll end up with inconsistent data. Discussing this in a larger context in the outbox pattern post [1]. This sort of issue is avoided when writing the metadata to a separate table as part of the DB transaction, which either will be committed or rolled back as one atomic unit.

> Would writing an additional transaction_metadata row for most of the application insert/updates slow things down?

You'd just do one insert into the metadata table per transaction. As change events themselves contain the transaction id, and that metadata table is keyed by transaction id, you can correlate the events downstream. So the overhead depends on how many operations you in your transactions already. Assuming you don't do just a single insert or update, but rather some select(s) and then some writes, the additional insert into the transaction metadata table typically shouldn't make a substantial difference.

Another option, exclusive to Postgres, would be to use write an event for the transaction metadata solely to the WAL using pg_logical_emit_message(), i.e. it won't be materialized in any table. It still can be picked up via logical decoding, we still need to add support for that record type to Debezium though (contributions welcome :).

[1] https://debezium.io/blog/2019/02/19/reliable-microservices-d...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: