Replace md5() with hashtext() #437
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello. When PostgreSQL 15+ is running in FIPS mode, it has all usage of MD5 disabled. One would see an error message:
The culprit seems to be usage of MD5 for load balancing:
que/lib/que/migrations/5/up.sql
Line 41 in 17fb2c3
I think the solution is to use a hashing algorithm that doesn't bother FIPS. And PostgreSQL's built-in
hashtext()function seems to check. As far as I understand the exact hashing algorithm is irrelevant.As a bonus, that
hashtextfunction is 5 times faster thanmd5. On my laptop it shows 142ms vs 27ms for 100k iterations.-- I tried this on PostgreSQL 15 and 18, but
hashtextseems to be old so probably will support earlier versions as well.