Created attachment 266984 [details] hast.conf Hi all, I am trying to set up hastd on FreeBSD 15.0-RELEASE, but I keep getting errors like [58519] g_dev_taste: g_dev_taste(hast/shared) failed to g_attach, error=6 /var/log/messages:{"time":"20260104190514","host":"nattaneo","facility":"[kern.notice]","msg":"kernel: : [1104] g_dev_taste: g_dev_taste(hast/shared) failed to g_attach, error=6" /var/log/messages:{"time":"20260105063137","host":"nattaneo","facility":"[syslog.err]","msg":"syslog-ng[26434]: Error processing log message: <30>1 2026-01-05T06:31:37.242261+00:00 >@<hastd: shared (primary) hastd 61114 - - [shared] (primary) Privileges successfully dropped." on the primary node and {"time":"20260110074150","host":"nodeb","facility":"[daemon.err]","msg":"hastd[45686]: Unable to receive header from tcp://10.255.255.1:18765: Operation timed out." on the secondary one. I create the device as explained in the handbook: hastctl create shared service hastd start hastctl role primary shared on the primary node and hastctl create shared service hastd start hastctl role secondary shared on the secondary. There are no firewall rules that might cause connection issues: [ale@hosta ~]$ nc -vz 10.255.255.2 8457 Connection to 10.255.255.2 8457 port [tcp/*] succeeded! [ale@hostb ~]$ nc -vz 10.255.255.1 8457 Connection to 10.255.255.1 8457 port [tcp/*] succeeded! For what it's worth, the root filesystem is ZFS, but the configuration is identical on both hosts (hast.conf file is attached) an d I am also attaching the output of gpart show and hastctl dump all. Anything that might be causing this since the same configuration used to work as expected on 14.3-RELEASE? Let me know if you need anything else, thank you
Created attachment 266985 [details] gpart show and hastctl dump all output
I've hit this exact problem when setting up HAST on FreeBSD 15.0 and decided to investigate, here is the summary: The timeout on the secondary node ("Unable to receive header") was traced to the parent/worker connection migration path in hastd (on primary) rather than the replication protocol itself. The connection migration code transfers a protocol name and a connected socket descriptor over a local AF_UNIX socketpair. The protocol name is sent using send(2), while the descriptor is sent separately using sendmsg(2) with SCM_RIGHTS. The receive side calls recv(2) with a buffer sized for the maximum protocol name length and uses MSG_WAITALL. On FreeBSD 15.0 this causes the receiver to wait indefinitely for the full buffer size rather than returning after receiving the protocol name. Because of this the primary never sends the HAST header and the resource doesn't appear in /dev/hast/. A review has been submitted with a patch that sends the protocol name and descriptor together using a single sendmsg()/recvmsg() exchange. With the patch applied, the primary successfully creates /dev/hast/, the secondary receives the HAST protocol header, and synchronization completes successfully.
Hi Martin, thanks a lot for the detailed summary! Is https://reviews.freebsd.org/D57511 the proposed change you mentioned? Let's see how that works out, thank you
(In reply to Alessandro Sagratini from comment #3) Hi Alessandro, that's right.
perfect, hopefully this issue will be fixed as soon as possible, thank you!
I independently reproduced this exact issue while testing HAST for a project (two FreeBSD 15.1-RELEASE VMs). Same symptom: primary stuck at degraded, secondary logging Unable to receive header from tcp://...: Operation timed out., and the same g_dev_taste ... failed to g_attach, error=6 kernel message. Diagnostic detail that may help confirm the root cause: a packet capture during a role primary attempt shows a completely clean TCP three-way handshake followed by ~20 seconds of total silence in both directions before the connection times out — confirming the network layer is healthy and the primary genuinely never transmits anything. 'procstat -t' on the primary's worker process shows kernel threads parked in sbwait with no forward progress, and 'truss -H' confirms zero connect/send/recv syscalls occur — consistent with Martin's diagnosis of the worker blocking on recv(2)/MSG_WAITALL in the connection-migration path. I also confirmed this is not 15-specific: pairing a FreeBSD 16.0-CURRENT node (main-n288684-420428718da7) with a 15.1-RELEASE node reproduces the identical failure, so the affected code path is still present in HEAD as of 2026-08-29.
Follow-up to my earlier reproduction report: I built hastd from a source tree with D57511 applied and tested it directly. Setup: two FreeBSD nodes, one running the patched hastd (built from a source checkout with D57511 applied — no other changes) acting as primary, the other running stock unpatched hastd as secondary. Same resource config as before. Result: hastctl list reports status: complete on both sides — previously it stuck at degraded indefinitely on the same setup with an unpatched primary. I also verified actual data replication, not just the status flag: writing through /dev/hast/<resource> on the primary showed the resource's dirty counter go from 0 to the extent size and back to 0 after the write, confirming the data was really synced to the secondary and the sync tracking cleared normally. One detail that may be useful: only the primary side needed the patch — the secondary ran unpatched hastd throughout and worked fine, consistent with the bug being entirely in the primary's own connection-migration path. That said, since any node can become primary in practice, patching all nodes is still the right move once this lands. This confirms the fix works completely, on top of the 16.0-CURRENT confirmation from my last comment. Thanks again to Martin for the diagnosis — hope this helps get D57511 through review.
*** This bug has been marked as a duplicate of bug 234576 ***
Oops, not a duplicate
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=cd8eef45d2d0296afe0226bde587f52eb0404516 commit cd8eef45d2d0296afe0226bde587f52eb0404516 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-09-08 20:55:15 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-09-20 16:51:12 +0000 hastd: Use fixed-length protocol names All communication between hastd nodes and internally between hastd and its worker children passes through the same pair of send / receive functions. The receive function uses recv(2) with the MSG_WAITALL flag, which in theory means we should never get a short read. However, when handing off a socket to a worker child, we also pass a variable-length string identifying the type of socket we're passing, and reading this string relies on a short read. This used to work because the arrival of the descriptor would interrupt the recv(2) call, but this bug was fixed when the AF_UNIX code was rewritten a while ago and hastd has been broken ever since. Fixing the length of the protocol name to four characters including the terminating null solves the short-read bug by never requiring a short read (nothing else in hastd requires one). Note that this issue appears to have been reported independently first by Alessandro Sagratini in PR 292322 and then by Martin Vidovic in D57511. I ended up going in a different direction than Martin's patch, but his analysis was invaluable, hence the double credit below. PR: 292322 Reported by: Martin Vidovic <xtronom@gmail.com> MFC after: 1 week Event: EuroBSDcon DevSummit 2026 Reviewed by: xtronom_gmail.com, kevans, glebius, gjb Differential Revision: https://reviews.freebsd.org/D59521 (cherry picked from commit b7e5c2e008f5b441611830ad3a0329de0882419e) sbin/hastd/proto.c | 15 +++++---------- sbin/hastd/proto_impl.h | 2 +- sbin/hastd/proto_socketpair.c | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=9401bfb06108e49cc125a237469886da34bb4f38 commit 9401bfb06108e49cc125a237469886da34bb4f38 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-09-08 20:55:15 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-09-20 16:51:17 +0000 hastd: Use fixed-length protocol names All communication between hastd nodes and internally between hastd and its worker children passes through the same pair of send / receive functions. The receive function uses recv(2) with the MSG_WAITALL flag, which in theory means we should never get a short read. However, when handing off a socket to a worker child, we also pass a variable-length string identifying the type of socket we're passing, and reading this string relies on a short read. This used to work because the arrival of the descriptor would interrupt the recv(2) call, but this bug was fixed when the AF_UNIX code was rewritten a while ago and hastd has been broken ever since. Fixing the length of the protocol name to four characters including the terminating null solves the short-read bug by never requiring a short read (nothing else in hastd requires one). Note that this issue appears to have been reported independently first by Alessandro Sagratini in PR 292322 and then by Martin Vidovic in D57511. I ended up going in a different direction than Martin's patch, but his analysis was invaluable, hence the double credit below. PR: 292322 Reported by: Martin Vidovic <xtronom@gmail.com> MFC after: 1 week Event: EuroBSDcon DevSummit 2026 Reviewed by: xtronom_gmail.com, kevans, glebius, gjb Differential Revision: https://reviews.freebsd.org/D59521 (cherry picked from commit b7e5c2e008f5b441611830ad3a0329de0882419e) sbin/hastd/proto.c | 15 +++++---------- sbin/hastd/proto_impl.h | 2 +- sbin/hastd/proto_socketpair.c | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-)
A commit in branch releng/14.4 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=1c821dc49b536cf2d925487324e0785a7a1400c6 commit 1c821dc49b536cf2d925487324e0785a7a1400c6 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-09-08 20:55:15 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2026-10-13 13:47:11 +0000 hastd: Use fixed-length protocol names All communication between hastd nodes and internally between hastd and its worker children passes through the same pair of send / receive functions. The receive function uses recv(2) with the MSG_WAITALL flag, which in theory means we should never get a short read. However, when handing off a socket to a worker child, we also pass a variable-length string identifying the type of socket we're passing, and reading this string relies on a short read. This used to work because the arrival of the descriptor would interrupt the recv(2) call, but this bug was fixed when the AF_UNIX code was rewritten a while ago and hastd has been broken ever since. Fixing the length of the protocol name to four characters including the terminating null solves the short-read bug by never requiring a short read (nothing else in hastd requires one). Note that this issue appears to have been reported independently first by Alessandro Sagratini in PR 292322 and then by Martin Vidovic in D57511. I ended up going in a different direction than Martin's patch, but his analysis was invaluable, hence the double credit below. Approved by: so Security: FreeBSD-EN-26:26.hastd PR: 292322 Reported by: Martin Vidovic <xtronom@gmail.com> MFC after: 1 week Event: EuroBSDcon DevSummit 2026 Reviewed by: xtronom_gmail.com, kevans, glebius, gjb Differential Revision: https://reviews.freebsd.org/D59521 (cherry picked from commit b7e5c2e008f5b441611830ad3a0329de0882419e) (cherry picked from commit 9401bfb06108e49cc125a237469886da34bb4f38) sbin/hastd/proto.c | 15 +++++---------- sbin/hastd/proto_impl.h | 2 +- sbin/hastd/proto_socketpair.c | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-)
A commit in branch releng/14.5 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=49baaf01c26af6a35a585bcf73e0009c2fd37ad6 commit 49baaf01c26af6a35a585bcf73e0009c2fd37ad6 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-09-08 20:55:15 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2026-10-13 14:03:00 +0000 hastd: Use fixed-length protocol names All communication between hastd nodes and internally between hastd and its worker children passes through the same pair of send / receive functions. The receive function uses recv(2) with the MSG_WAITALL flag, which in theory means we should never get a short read. However, when handing off a socket to a worker child, we also pass a variable-length string identifying the type of socket we're passing, and reading this string relies on a short read. This used to work because the arrival of the descriptor would interrupt the recv(2) call, but this bug was fixed when the AF_UNIX code was rewritten a while ago and hastd has been broken ever since. Fixing the length of the protocol name to four characters including the terminating null solves the short-read bug by never requiring a short read (nothing else in hastd requires one). Note that this issue appears to have been reported independently first by Alessandro Sagratini in PR 292322 and then by Martin Vidovic in D57511. I ended up going in a different direction than Martin's patch, but his analysis was invaluable, hence the double credit below. Approved by: so Security: FreeBSD-EN-26:26.hastd PR: 292322 Reported by: Martin Vidovic <xtronom@gmail.com> MFC after: 1 week Event: EuroBSDcon DevSummit 2026 Reviewed by: xtronom_gmail.com, kevans, glebius, gjb Differential Revision: https://reviews.freebsd.org/D59521 (cherry picked from commit b7e5c2e008f5b441611830ad3a0329de0882419e) (cherry picked from commit 9401bfb06108e49cc125a237469886da34bb4f38) sbin/hastd/proto.c | 15 +++++---------- sbin/hastd/proto_impl.h | 2 +- sbin/hastd/proto_socketpair.c | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-)
A commit in branch releng/15.1 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=c8fe55b4726ae56ceaa6d0828403780dcef72c54 commit c8fe55b4726ae56ceaa6d0828403780dcef72c54 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-09-08 20:55:15 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2026-10-13 14:10:21 +0000 hastd: Use fixed-length protocol names All communication between hastd nodes and internally between hastd and its worker children passes through the same pair of send / receive functions. The receive function uses recv(2) with the MSG_WAITALL flag, which in theory means we should never get a short read. However, when handing off a socket to a worker child, we also pass a variable-length string identifying the type of socket we're passing, and reading this string relies on a short read. This used to work because the arrival of the descriptor would interrupt the recv(2) call, but this bug was fixed when the AF_UNIX code was rewritten a while ago and hastd has been broken ever since. Fixing the length of the protocol name to four characters including the terminating null solves the short-read bug by never requiring a short read (nothing else in hastd requires one). Note that this issue appears to have been reported independently first by Alessandro Sagratini in PR 292322 and then by Martin Vidovic in D57511. I ended up going in a different direction than Martin's patch, but his analysis was invaluable, hence the double credit below. Approved by: so Security: FreeBSD-EN-26:26.hastd PR: 292322 Reported by: Martin Vidovic <xtronom@gmail.com> MFC after: 1 week Event: EuroBSDcon DevSummit 2026 Reviewed by: xtronom_gmail.com, kevans, glebius, gjb Differential Revision: https://reviews.freebsd.org/D59521 (cherry picked from commit b7e5c2e008f5b441611830ad3a0329de0882419e) (cherry picked from commit cd8eef45d2d0296afe0226bde587f52eb0404516) sbin/hastd/proto.c | 15 +++++---------- sbin/hastd/proto_impl.h | 2 +- sbin/hastd/proto_socketpair.c | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-)
I just tested the change on FreeBSD 15.1-p5 and hast indeed started working again. I will obviously check in the next few days, but it's good to see it is back working :)