Live data from Hacker News

Show HN: Pg_disorder – shuffle or reverse unordered SELECT results

github.com

1–3 of 3 posts

Show HN: Pg_disorder – shuffle or reverse unordered SELECT results

#1
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!

Show HN: Pg_disorder – shuffle or reverse unordered SELECT results
github.com

Re: Show HN: Pg_disorder – shuffle or reverse unordered SELECT results

#3

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

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