frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Locks in PostgreSQL: 3. Other locks (2020)

https://habr.com/en/companies/postgrespro/articles/504498/
60•fanf2•11h ago

Comments

semiquaver•11h ago
Don’t skip the discussion on advisory locks. In my experience nearly every nontrivial application that spans multiple machines has concurrency bugs that advisory locks are perfectly suited to fix.
leftnode•10h ago
Yes! Just implemented these the other day for a long running process that I didn't want to lock a specific row for.
GeertJohan•10h ago
They are great, although I wouldnt use the articles advice on using hashtext to get a number for the lock. This may cause collisions, especially when used with a large number of locks.

In a project Im working on we have a single go package that holds a list of all advisory lock numbers as constants.

dpedu•8h ago
These are great. Some time ago I was tasked with writing installation tooling for a startup's data analysis product, which was built as a distributed system. The system used a SQL database to store metadata, so every host needed the SQL database's connection details. Using an advisory lock to decide which host initializes the database schema made everything so much simpler - just install on all your hosts at once, in parallel, and don't worry about it.

This was MySQL but its advisory locks are pretty similar to Postgres.

It's also nice that the lock is released when the database connection terminates. Really easy to use. If you need exactly one of something running constantly, you can launch however many processes and let all but one spin trying to acquire the lock. When one dies and closes its SQL connection, thus releasing the lock, another will obtain the lock and begin work more or less instantly.

They're infinitely useful!

sa46•8h ago
Advisory locks aren’t all sunshine and rainbows. They can only be unlocked by the Postgres connection that acquired the lock. That means you need to track the connection, typically by dedicating a connection to the job that needs locking.

Here’s a good issue describing the tradeoffs between a lock table and advisory locks.

https://github.com/bensheldon/good_job/discussions/831

FreakLegion•2h ago
Do people use advisory locks as the actual locking mechanism? I've always used them to synchronize access to a flag on the target resource, so the advisory lock is only held long enough to query or update that resource as locked. The alternative seems, yes, incredibly brittle.

I failed to recreate the 1996 Space Jam website with Claude

https://j0nah.com/i-failed-to-recreate-the-1996-space-jam-website-with-claude/
327•thecr0w•9h ago•269 comments

Mechanical power generation using Earth's ambient radiation

https://www.science.org/doi/10.1126/sciadv.adw6833
62•defrost•5h ago•24 comments

Uninitialized garbage on ia64 can be deadly (2004)

https://devblogs.microsoft.com/oldnewthing/20040119-00/?p=41003
31•HeliumHydride•3d ago•12 comments

The C++ standard for the F-35 Fighter Jet [video]

https://www.youtube.com/watch?v=Gv4sDL9Ljww
199•AareyBaba•9h ago•197 comments

Dollar-stores overcharge customers while promising low prices

https://www.theguardian.com/us-news/2025/dec/03/customers-pay-more-rising-dollar-store-costs
274•bookofjoe•12h ago•430 comments

Google Titans architecture, helping AI have long-term memory

https://research.google/blog/titans-miras-helping-ai-have-long-term-memory/
405•Alifatisk•14h ago•140 comments

Socialist Ends by Market Means: A History

https://lucasvance.github.io/2100/history/
3•sirponm•40m ago•0 comments

Vibe Coding: Empowering and Imprisoning

https://www.anildash.com/2025/12/02/vibe-coding-empowering-and-imprisoning/
19•zdw•5d ago•8 comments

Work disincentives hit the near-poor hardest (2022)

https://www.niskanencenter.org/work-disincentives-hit-the-near-poor-hardest-why-and-what-to-do-ab...
33•folump•5d ago•10 comments

An Interactive Guide to the Fourier Transform

https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/
151•pykello•5d ago•20 comments

Bag of words, have mercy on us

https://www.experimental-history.com/p/bag-of-words-have-mercy-on-us
63•ntnbr•4h ago•46 comments

Scala 3 slowed us down?

https://kmaliszewski9.github.io/scala/2025/12/07/scala3-slowdown.html
190•kmaliszewski•12h ago•112 comments

What the heck is going on at Apple?

https://www.cnn.com/2025/12/06/tech/apple-tim-cook-leadership-changes
69•methuselah_in•10h ago•71 comments

Show HN: Cdecl-dump - represent C declarations visually

https://github.com/bbu/cdecl-dump
11•bluetomcat•2h ago•3 comments

The Anatomy of a macOS App

https://eclecticlight.co/2025/12/04/the-anatomy-of-a-macos-app/
196•elashri•14h ago•57 comments

A two-person method to simulate die rolls (2023)

https://blog.42yeah.is/algorithm/2023/08/05/two-person-die.html
54•Fraterkes•2d ago•31 comments

Build a DIY magnetometer with a couple of seasoning bottles

https://spectrum.ieee.org/listen-to-protons-diy-magnetometer
67•nullbyte808•1w ago•17 comments

Spinlocks vs. Mutexes: When to Spin and When to Sleep

https://howtech.substack.com/p/spinlocks-vs-mutexes-when-to-spin
37•birdculture•2h ago•8 comments

Nested Learning: A new ML paradigm for continual learning

https://research.google/blog/introducing-nested-learning-a-new-ml-paradigm-for-continual-learning/
81•themgt•12h ago•2 comments

Millions of Americans mess up their taxes, but a new law will help

https://www.wakeuptopolitics.com/p/millions-of-americans-mess-up-their
43•toomuchtodo•8h ago•25 comments

The state of Schleswig-Holstein is consistently relying on open source

https://www.heise.de/en/news/Goodbye-Microsoft-Schleswig-Holstein-relies-on-Open-Source-and-saves...
518•doener•13h ago•236 comments

Estimates are difficult for developers and product owners

https://thorsell.io/2025/12/07/estimates.html
155•todsacerdoti•7h ago•173 comments

Minimum Viable Arduino Project: Aeropress Timer

https://netninja.com/2025/12/01/minimum-viable-arduino-project-aeropress-timer/
19•surprisetalk•5d ago•9 comments

Java Hello World, LLVM Edition

https://www.javaadvent.com/2025/12/java-hello-world-llvm-edition.html
166•ingve•15h ago•60 comments

Toyota Unintended Acceleration and the Big Bowl of "Spaghetti" Code (2013)

https://www.safetyresearch.net/toyota-unintended-acceleration-and-the-big-bowl-of-spaghetti-code/
12•SoKamil•2h ago•5 comments

Building a Toast Component

https://emilkowal.ski/ui/building-a-toast-component
97•FragrantRiver•4d ago•33 comments

Evidence from the One Laptop per Child program in rural Peru

https://www.nber.org/papers/w34495
99•danso•7h ago•90 comments

Over fifty new hallucinations in ICLR 2026 submissions

https://gptzero.me/news/iclr-2026/
459•puttycat•13h ago•364 comments

Proxmox delivers its software-defined datacenter contender and VMware escape

https://www.theregister.com/2025/12/05/proxmox_datacenter_manager_1_stable/
64•Bender•5h ago•1 comments

Noninvasive imaging could replace finger pricks for measuring blood glucose

https://news.mit.edu/2025/noninvasive-imaging-could-replace-finger-pricks-diabetes-1203
3•ivewonyoung•21m ago•0 comments