From 7dce8d2900395da0219ea466a7e0dc53b7bdf42c Mon Sep 17 00:00:00 2001 From: Robert Cowham Date: Fri, 23 Aug 2024 14:46:39 +1000 Subject: [PATCH] Fix errors with SQL constraints for rmt-Journal records Note this may create problems when parsing older p4d logs which did not have completion records for rmt-Journal. --- p4dlog.go | 2 +- p4dlog_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/p4dlog.go b/p4dlog.go index 0a32e0a..4330857 100644 --- a/p4dlog.go +++ b/p4dlog.go @@ -1277,7 +1277,7 @@ func (fp *P4dFileParser) addCommand(newCmd *Command, hasTrackInfo bool) { func cmdHasNoCompletionRecord(cmdName string) bool { return cmdName == "rmt-FileFetch" || cmdName == "rmt-FileFetchMulti" || - cmdName == "rmt-Journal" || + // cmdName == "rmt-Journal" || cmdName == "rmt-JournalPos" || cmdName == "pull" } diff --git a/p4dlog_test.go b/p4dlog_test.go index 3521a8a..156c096 100644 --- a/p4dlog_test.go +++ b/p4dlog_test.go @@ -958,9 +958,9 @@ Perforce server info: output := parseLogLines(testInput) assert.Equal(t, 3, len(output)) //assert.Equal(t, "", output[2]) - assert.JSONEq(t, cleanJSON(`{"processKey":"b9ec8da8ea642419a06f8ac4060f261c","cmd":"rmt-Journal","pid":17916,"lineNo":4,"user":"svc_p4d_ha_chi","workspace":"unknown","completedLapse":0.202,"ip":"10.5.70.41","app":"p4d/2019.2/LINUX26X86_64/1908095","args":"","startTime":"2020/03/11 06:08:16","endTime":"2020/03/11 06:08:16","running":1,"rpcMsgsOut":1,"rpcHimarkFwd":280100,"rpcHimarkRev":278660,"cmdError":false,"tables":[{"tableName":"counters","pagesIn":6,"pagesCached":2,"readLocks":6,"getRows":6}]}`), + assert.JSONEq(t, cleanJSON(`{"processKey":"b9ec8da8ea642419a06f8ac4060f261c","cmd":"rmt-Journal","pid":17916,"lineNo":4,"user":"svc_p4d_ha_chi","workspace":"unknown","completedLapse":0.202,"ip":"10.5.70.41","app":"p4d/2019.2/LINUX26X86_64/1908095","args":"","startTime":"2020/03/11 06:08:16","endTime":"2020/03/11 06:08:16","running":2,"rpcMsgsOut":1,"rpcHimarkFwd":280100,"rpcHimarkRev":278660,"cmdError":false,"tables":[{"tableName":"counters","pagesIn":6,"pagesCached":2,"readLocks":6,"getRows":6}]}`), cleanJSON(output[0])) - assert.JSONEq(t, cleanJSON(`{"processKey":"b9ec8da8ea642419a06f8ac4060f261c.12","cmd":"rmt-Journal","pid":17916,"lineNo":12,"user":"svc_p4d_ha_chi","workspace":"unknown","completedLapse":0.001,"ip":"10.5.70.41","app":"p4d/2019.2/LINUX26X86_64/1908095","args":"","startTime":"2020/03/11 06:08:16","endTime":"2020/03/11 06:08:16","running":1,"rpcMsgsOut":1,"rpcHimarkFwd":280100,"rpcHimarkRev":278660,"cmdError":false,"tables":[{"tableName":"counters","pagesIn":1,"pagesCached":2,"readLocks":1,"getRows":1}]}`), + assert.JSONEq(t, cleanJSON(`{"processKey":"b9ec8da8ea642419a06f8ac4060f261c.12","cmd":"rmt-Journal","pid":17916,"lineNo":12,"user":"svc_p4d_ha_chi","workspace":"unknown","completedLapse":0.001,"ip":"10.5.70.41","app":"p4d/2019.2/LINUX26X86_64/1908095","args":"","startTime":"2020/03/11 06:08:16","endTime":"2020/03/11 06:08:16","running":2,"rpcMsgsOut":1,"rpcHimarkFwd":280100,"rpcHimarkRev":278660,"cmdError":false,"tables":[{"tableName":"counters","pagesIn":1,"pagesCached":2,"readLocks":1,"getRows":1}]}`), cleanJSON(output[1])) assert.JSONEq(t, cleanJSON(`{"processKey":"b9f9aee10027df004a0e35a3c9931e27","cmd":"user-change","pid":15855,"lineNo":2,"user":"fred","workspace":"fred_ws","completedLapse":0.276,"ip":"10.1.4.213/10.1.3.243","app":"Helix P4V/NTX64/2019.2/1904275/v86","args":"-i","startTime":"2020/03/11 06:08:16","endTime":"2020/03/11 06:08:17","running":1,"uCpu":4,"sCpu":4,"diskIn":256,"diskOut":240,"maxRss":9212,"rpcMsgsIn":3,"rpcMsgsOut":5,"rpcHimarkFwd":280100,"rpcHimarkRev":280100,"rpcRcv":0.19,"cmdError":false,"tables":[{"tableName":"counters","pagesIn":7,"pagesOut":6,"pagesCached":2,"readLocks":1,"writeLocks":2,"getRows":3,"putRows":2},{"tableName":"monitor","pagesIn":2,"pagesOut":4,"pagesCached":256,"writeLocks":2,"putRows":2},{"tableName":"protect","pagesIn":9,"pagesCached":7,"readLocks":1,"posRows":1,"scanRows":345,"peekCount":1},{"tableName":"storagemasterup_R","totalReadWait":1,"totalReadHeld":2,"totalWriteWait":3,"totalWriteHeld":4},{"tableName":"storageup_R","totalReadWait":1,"totalReadHeld":2,"totalWriteWait":3,"totalWriteHeld":4},{"tableName":"trigger_swarm.changesave","triggerLapse":0.076}]}`), cleanJSON(output[2]))