Skip to content

Commit 0f13c8c

Browse files
committed
db: log full path to WAL file in disk slow info
Log full path to WAL file in disk slow info so it's explicit if the WAL file is on the primary or secondary. Fixes #5328
1 parent dd61365 commit 0f13c8c

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

vfs/disk_health.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,15 +466,20 @@ func (i DiskSlowInfo) String() string {
466466

467467
// SafeFormat implements redact.SafeFormatter.
468468
func (i DiskSlowInfo) SafeFormat(w redact.SafePrinter, _ rune) {
469+
fullPath, err := filepath.Abs(i.Path)
470+
if err != nil {
471+
w.Printf("failed to get absolute path %s: %s", redact.Safe(i.Path), err)
472+
fullPath = i.Path
473+
}
469474
switch i.OpType {
470475
// Operations for which i.WriteSize is meaningful.
471476
case OpTypeWrite, OpTypeSyncTo, OpTypePreallocate:
472477
w.Printf("disk slowness detected: %s on file %s (%d bytes) has been ongoing for %0.1fs",
473-
redact.Safe(i.OpType.String()), redact.Safe(filepath.Base(i.Path)),
478+
redact.Safe(i.OpType.String()), redact.Safe(fullPath),
474479
redact.Safe(i.WriteSize), redact.Safe(i.Duration.Seconds()))
475480
default:
476481
w.Printf("disk slowness detected: %s on file %s has been ongoing for %0.1fs",
477-
redact.Safe(i.OpType.String()), redact.Safe(filepath.Base(i.Path)),
482+
redact.Safe(i.OpType.String()), redact.Safe(fullPath),
478483
redact.Safe(i.Duration.Seconds()))
479484
}
480485
}

vfs/disk_health_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,3 +635,24 @@ func TestDiskHealthChecking_Filesystem_Close(t *testing.T) {
635635
}
636636
wg.Wait()
637637
}
638+
639+
func TestDiskSlowInfo(t *testing.T) {
640+
info := DiskSlowInfo{
641+
Path: "/some/really/deep/path/to/wal/000123.log",
642+
OpType: OpTypeWrite,
643+
WriteSize: 123,
644+
Duration: 5 * time.Second,
645+
}
646+
647+
result := info.String()
648+
649+
// Essential information should be present
650+
require.Contains(t, result, "disk slowness detected")
651+
require.Contains(t, result, "write")
652+
require.Contains(t, result, "/some/really/deep/path/to/wal/000123.log")
653+
require.Contains(t, result, "(123 bytes)")
654+
require.Contains(t, result, "5.0s")
655+
656+
// Should not contain just the filename without full path
657+
require.NotContains(t, result, " 000123.log ")
658+
}

0 commit comments

Comments
 (0)