Bug 16236 - Optional TDB try_mutex fallback logs DBG_ERR instead of silent fallback on platforms without robust mutexes
Summary: Optional TDB try_mutex fallback logs DBG_ERR instead of silent fallback on pl...
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.25.0rc*
Hardware: All OpenBSD
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-09-08 05:12 UTC by Bjorn Ketelaars
Modified: 2026-09-11 07:29 UTC (History)
4 users (show)

See Also:


Attachments
Proposed fix (1.04 KB, patch)
2026-09-08 05:12 UTC, Bjorn Ketelaars
no flags Details
gate on HAVE_ROBUST_MUTEXES (946 bytes, patch)
2026-09-08 14:31 UTC, Bjorn Ketelaars
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bjorn Ketelaars 2026-09-08 05:12:35 UTC
Created attachment 19194 [details]
Proposed fix

When running smbstatus (or other CLI tools) on platforms without POSIX robust mutex support (e.g., OpenBSD), the standard error output is polluted with multiple "mutexes requested but not available" error messages on debug level 0 (DBG_ERR).

This behavior was introduced in commit 89b16e8a0f89af2336bdaa18d39eb3eb25d5ae77 ("s3: Warn if no mutexes available at runtime").

In dbwrap_open.c and tdb_wrap.c, try_mutex defaults to true for TDB databases. When tdb_runtime_check_for_robust_mutexes() evaluates to false, Samba logs a high-priority DBG_ERR before falling back to POSIX fcntl file locking.

try_mutex is a best-effort check. Falling back to POSIX file locking when an optional OS capability is missing is expected operational flow, not an unrecoverable error (DBG_ERR). Hard mutex requirements are already explicitly handled by dbwrap_tdb_require_mutexes.

As a result, out-of-the-box installations on non-robust-mutex OSs emit error messages during normal operation.

Actual Result:
CLI tools output multiple mutexes requested but not available lines to stderr on level 0.

Expected Result:
Samba silently falls back to fcntl locking when try_mutex fails. If logging is desired, it should use DBG_INFO (level 2) or DBG_NOTICE (level 1) so standard CLI output on level 0 remains clean.

Proposed Fix:
Revert commit 89b16e8a0f89af2336bdaa18d39eb3eb25d5ae77 to restore clean silent fallback for try_mutex.
Comment 1 Stefan Metzmacher 2026-09-08 07:12:54 UTC
I'd gate the messages on #ifdef HAVE_ROBUST_MUTEXES
Comment 2 Bjorn Ketelaars 2026-09-08 14:30:40 UTC
(In reply to Stefan Metzmacher from comment #1)

Makes sense. Guarding the DBG_ERR log calls with #ifdef HAVE_ROBUST_MUTEXES fixes the CLI noise on OpenBSD (and other non-robust-mutex platforms) while preserving the runtime warning on platforms where robust mutex support was compiled in.

New patch attached.
Comment 3 Bjorn Ketelaars 2026-09-08 14:31:34 UTC
Created attachment 19196 [details]
gate on HAVE_ROBUST_MUTEXES
Comment 4 Volker Lendecke 2026-09-08 15:57:06 UTC
Fix looks good to me. Samba has some formalism to go through gitlab with a git commit message etc. Do you want to do that yourself or do you want us to take care of that?
Comment 5 Bjorn Ketelaars 2026-09-08 17:31:09 UTC
(In reply to Volker Lendecke from comment #4)

If you don't mind taking care of GitLab / commit message, that would be greatly appreciated.
Comment 6 Volker Lendecke 2026-09-09 08:22:44 UTC
(In reply to Bjorn Ketelaars from comment #5)
> If you don't mind taking care of GitLab / commit message, that would be
> greatly appreciated.

Ah, I forgot: We need a DCO according to https://www.samba.org/samba/devel/copyright-policy.html or a confirmation that you are doing the work as a private hobby or so.
Comment 7 Bjorn Ketelaars 2026-09-09 19:29:11 UTC
(In reply to Volker Lendecke from comment #6)

I am a hobbyist contributor, so if I have understood the DCO correctly, it might not apply here. I have gone ahead and reviewed the contribution wiki and opened up a pull request. Hope this is helpful!

https://gitlab.com/samba-team/samba/-/merge_requests/4700
Comment 8 Samba QA Contact 2026-09-11 07:29:03 UTC
This bug was referenced in samba master:

3a79fa00ffd9c7f3b0ef10ba458cf16f2c4ab8ec
4d45e61a158143194efb91974ab667ba341b0536