Skip to content

[-] build remote log parser server paths with forward slashes - #1607

Merged
pashagolub merged 3 commits into
v7from
fix/logparser-remote-path
Oct 17, 2026
Merged

pashagolub merged 3 commits into
v7from
fix/logparser-remote-path

Conversation

@pashagolub

@pashagolub pashagolub commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

On a Windows host the remote log parser probed the server's log with filepath.Join, so a Linux server got \var\lib\..., answered 58P01, and server_log_event_counts was never sent. Server paths now go through one helper that always uses /.

 parseLogs (remote mode)
   checkHasRemotePrivileges
-    pg_read_file(filepath.Join(dir, file), 0, 0)
+    pg_read_file(serverPath(dir, file), 0, 0)    // path.Join
   remoteFileSizes
-    key = filepath.ToSlash(filepath.Join(dir, name))
+    key = serverPath(dir, name)
   openRemote
     pgremote.Open(Dir: dir)                       // joins with path.Join already

Also cherry-picks #1603 from master: AGENTS.md scopes the AI attribution rule to external contributors and points at GitHub releases for release notes.

Server path call sites checked:

Call site Status
logparser.go checkHasRemotePrivileges probe fixed
logparser_stream.go remoteFileSizes map key serverPath (was already /)
logparser_stream.go remoteFileSizes lookup unchanged, path comes from pgremote
logparser_stream.go openRemote unchanged, pgremote's joinRemote uses path.Join
local mode (openLocal, checkHasLocalPrivileges) stays on filepath

Evidence

  • Before: TestCheckHasRemotePrivilegesUsesServerPath (expects /var/lib/postgresql/18/docker/log/postgresql-2026-10-16_203849.log) fails on Windows with an unmatched expectation. pgwatch from origin/v7 on Windows against postgres:18 in Docker with log_destination = jsonlog:
    [ERROR] [metric:server_log_event_counts] [error:ERROR: could not open file "\var\lib\postgresql\18\docker\log\postgresql-2026-10-17_072656.log" for reading: No such file or directory (SQLSTATE 58P01)] couldn't parse logs remotely, lacking required privileges
    
    0 server_log_event_counts rows in the sink.
    After: go test -p 1 ./pkg/reaper passes on Windows; golangci-lint run ./pkg/reaper/... reports 0 issues. Same setup:
    [DEBUG] [sql:select pg_read_file($1, 0, 0)] [args:[/var/lib/postgresql/18/docker/log/postgresql-2026-10-17_072656.log]] [commandTag:SELECT 1]
    {"metric":"server_log_event_counts","data":[{..."error":4,"error_total":4,...}],"dbname":"t005"}
    
    7 rows in ~75 s.

Existing mocks that expected the probe as filepath.Join now expect path.Join, so they assert the server path on Windows too.

Merge Danger

Door: two-way

Blast Radius: small

Remote log parsing only. Linux and macOS hosts send the same paths as before; Windows hosts start sending / paths, which PostgreSQL on any OS accepts.

On a Windows host checkHasRemotePrivileges probed the log file with
filepath.Join, so a Linux server got a backslash path, answered 58P01, and
server_log_event_counts was never sent ("lacking required privileges").

- add serverPath (path.Join) for every path sent to the server
- use it in checkHasRemotePrivileges and remoteFileSizes; local mode keeps filepath
- assert the probe argument holds only "/"; mocks expect server paths via path.Join
- add the spec and its task list
@pashagolub pashagolub changed the title [*] build remote log parser server paths with forward slashes [-] build remote log parser server paths with forward slashes Oct 17, 2026
)

* [*] scope `AGENTS.md` AI attribution rule to external contributors

* [+] point `AGENTS.md` at GitHub releases for release notes
@pashagolub pashagolub self-assigned this Oct 17, 2026
@pashagolub pashagolub added the bug Something isn't working label Oct 17, 2026
@pashagolub
pashagolub merged commit 0d0369a into v7 Oct 17, 2026
4 checks passed
@pashagolub
pashagolub deleted the fix/logparser-remote-path branch October 17, 2026 07:36
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 39014149448

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Warning

No base build found for commit 7725207 on v7.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 89.709%

Details

  • Patch coverage: 3 of 3 lines across 2 files are fully covered (100%).

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 5607
Covered Lines: 5030
Line Coverage: 89.71%
Coverage Strength: 0.9 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants