Urgent.News

What's breaking now, across thousands of outlets.

Tech

A PostgreSQL mirror that loses nothing, even when the load fails

You have an application database and you want a copy of one of its tables somewhere else, for reporting. Copying the whole table every night works until the table gets big, or until you need the deletes too. The usual answer is change data capture: read the inserts, updates and deletes from PostgreSQL's write-ahead log and apply them to the copy. The usual tool for that is Debezium, which…

This account describes a PostgreSQL mirror that reliably copies table changes, even in the event of a load failure. The system uses PostgreSQL's built-in logical replication features, which are leveraged by the Hydra ETL tool. The implementation is simple, requiring only Docker and Python to set up. The process begins by cloning a repository that contains the necessary scripts and SQL files.

Upon running the system for the first time, it creates a publication and a replication slot in the source database, followed by the creation of a mirror table in the destination database. The destination then applies the received changes using an upsert mode, which ensures that all insertions and updates overwrite existing rows, while deletions are also applied.

If a failure occurs during the load process, the mirror maintains its integrity by adhering to the constraints defined in the application database, such as checking for non-negative amounts. The system demonstrates this robustness through a scenario where a new rule is added to the mirror database that prohibits negative amounts, and a bad order with a negative amount is intentionally inserted into the source database.

Despite this failure, the mirror successfully reflects the majority of the changes in the destination database, maintaining data consistency and reliability.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Server-Side Rendering on Country Subdomains: What We Got Wrong First

Server-Side Rendering on Country Subdomains: What We Got Wrong First 24ad.info is a classifieds site where every country has its own subdomain — pl.24ad.info , de.24ad.info , gb.24ad.info — all served…

  • 24ad.info struggled with proper first HTML responses and metadata for country subdomains.
  • Implemented geo-redirect as 301 instead of temporary 302, causing permanent redirection issues.
  • Injected country-specific data into server-rendered pages, but caused mix of listings on home page.

Animate Text on Scroll with SplitFX in 3 Simple Steps

Text animations can make a website more engaging by revealing content as visitors scroll through the page. These effects can draw attention to headings, section titles, and other important content…

  • Install SplitFX via npm or load from CDN
  • Create SplitFX instance and define animation
  • Use animateOnScroll() to trigger animation

Your PyTorch Code on Trainium: What Actually Breaks

AWS Trainium chips cost less per training run than equivalent GPU instances, but historically you had to rewrite your training loop around the Neuron SDK. TorchNeuron changes that.

  • Trainium offers lower costs per training run compared to GPU instances
  • TorchNeuron simplifies PyTorch code porting to Trainium
  • Unsupported operations include dynamic control flow and sparse tensors

More from Monday 9 November →