Settings

Theme

Show HN: Pg_disorder – shuffle or reverse unordered SELECT results

github.com

1 points by viralpraxis · 2 comments · 1 min read

Reader

Hey HN!

I'm interested in chaos engineering, automatically detecting flaky tests, and, more generally, building tools that can find/trigger invalid states in software systems.

My latest experiment is pg_disorder, a PostgreSQL extension that automatically shuffles (or reverses) the results of `SELECT` queries without an `ORDER BY` clause. While the order of rows isn't specified, applications (sometimes) implicitly assume that rows will be returned in insertion order. The project was initially aimed at finding flaky tests, but it also helped uncover bugs in projects like Gitea and Rails (see references in the repo).

Some DBMSs have this feature built-in, e.g. SQLite's `reverse_unordered_selects` pragma, but PostgreSQL doesn't.

I'd love to hear your thoughts and feedback!

1 thread
gaya3bollineni

Interesting approach. How often do you find queries unintentionally relying on the default row order?

  • viralpraxisOP

    Every project I tested (mid- to large-sized) had some flaky tests caused by relying on the default row order. In my evaluation of 10 popular PG-based projects, most of them (6 or 7, although its hard to say for sure before sending patches and getting feedback) had at least one application-level bug related to this assumption. This probably isnt a very representative sample, but it at least shows that this is not a purely theoretical issue

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection