Skip to content

Conversation

@akostadinov
Copy link

@akostadinov akostadinov commented Oct 8, 2025

Hello. When PostgreSQL 15+ is running in FIPS mode, it has all usage of MD5 disabled. One would see an error message:

ERROR -- : [ActiveJob] Failed enqueuing UpdateJob to Que(default): PG::InternalError (ERROR: could not compute MD5 hash: unsupported

The culprit seems to be usage of MD5 for load balancing:

ORDER BY md5(pid::text || id::text)

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 hashtext function is 5 times faster than md5. On my laptop it shows 142ms vs 27ms for 100k iterations.

zync=# \timing on
Timing is on.
zync=# SELECT count(distinct md5(n::text)) FROM generate_series(1, 100000) n;
 count  
--------
 100000
(1 row)

Time: 142.511 ms

zync=# SELECT count(distinct hashtext(n::text)) FROM generate_series(1, 100000) n;
 count  
--------
 100000
(1 row)

Time: 27.405 ms

-- I tried this on PostgreSQL 15 and 18, but hashtext seems to be old so probably will support earlier versions as well.

akostadinov added a commit to akostadinov/zync that referenced this pull request Oct 8, 2025
This is a temporary patch until upstream fix is merged, see
que-rb/que#437
akostadinov added a commit to akostadinov/zync that referenced this pull request Oct 8, 2025
This is a temporary patch until upstream fix is merged, see
que-rb/que#437
akostadinov added a commit to akostadinov/zync that referenced this pull request Oct 8, 2025
This is a temporary patch until upstream fix is merged, see
que-rb/que#437
akostadinov added a commit to akostadinov/zync that referenced this pull request Oct 8, 2025
This is a temporary patch until upstream fix is merged, see
que-rb/que#437
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant