nsmcp::EpisodeOverview method poolFullEvents (protected)
<instance of nsmcp::EpisodeOverview> poolFullEvents server from \ to bucket
Defined in /usr/local/ns/tcl/nsmcp/episode-overview.tcl
A fixed tail budget prevents the first-pass overview from scanning a large production error.log. Unread earlier bytes remain unknown.
- Parameters:
- server (required)
- from (required)
- to (required)
- bucket (required)
- Testcases:
- No testcase defined.
Source code: set slots [expr {($to-$from)/$bucket}] if {[catch {ns_info log} path]} { return {available boolean false reason string current-system-log-unavailable} } if {$path eq "" || ![file isfile $path] || ![file readable $path]} { return {available boolean false reason string current-system-log-unavailable} } file stat $path before set size [file size $path] set scanBudget 67108864 set low [expr {max(0,$size-$scanBudget)}] set counts {} set reportedSuppressed {} set occurrenceCounts {} set occurrenceWindows {} set attributedSuppressed 0 set unallocatedSuppressed 0 set suppressionPeaks {} set lastReportAt {} set lastReportProcess {} set strongest {} set matched 0 set warnings 0 set examined 0 set candidates 0 set parsed 0 set unparsedExample {} set otherServer 0 set invalidTimestamps 0 set outsideWindow 0 set channel [open $path rb] try { fconfigure $channel -translation binary -encoding binary seek $channel $low if {$low>0} { seek $channel [expr {$low-1}] set preceding [read $channel 1] seek $channel $low if {$preceding ne "\n"} {gets $channel} } while {[tell $channel]<$size && [gets $channel line]>=0} { if {[tell $channel]>$size} {break} incr examined if {[string first {All available connections are used, waiting } $line]<0 || [string length $line]>8192} {continue} incr candidates # The native message is stable, while the log prefix can be # decorated by a log writer or change across core versions. if {![regexp {\[([^] ]+) pool ([^]]*)\][ \t]+All available connections are used, waiting[ \t]+([0-9]+)[ \t]+idle[ \t]+([0-9]+)[ \t]+current[ \t]+([0-9]+)} $line -> loggedServer pool waiting idle current]} { if {$unparsedExample eq ""} {set unparsedExample [string range $line 0 511]} continue } incr parsed if {$loggedServer ne $server} {incr otherServer; continue} set severity [expr {[regexp {(^|[ \t])Warning:} $line] ? "Warning" : "Notice"}] set suppressed 0 set suppressionKind {} regexp {, suppressed ([0-9]+) repeated (notices since last notice|pool-full events since last report)} $line -> suppressed suppressionKind if {![regexp {([0-9]{2}/[A-Za-z]{3}/[0-9]{4}:[0-9]{2}:[0-9]{2}:[0-9]{2})} $line -> stamp]} {incr invalidTimestamps; continue} set at [::nsmcp::logRecordParser timestampSeconds $stamp] if {$at eq ""} {incr invalidTimestamps; continue} if {$pool eq ""} {set pool default} # The leading component changes on the observed process restart. # A report from an older process cannot bound this one's repeats. set process {} regexp {\[([0-9]+)\.[0-9]+\]} $line -> process set previous {} if {$process ne "" && [dict exists $lastReportAt $pool] && [dict get $lastReportProcess $pool] eq $process} { set candidate [dict get $lastReportAt $pool] if {$candidate<=$at} {set previous $candidate} } dict set lastReportAt $pool $at dict set lastReportProcess $pool $process if {$at<$from || $at>=$to} {incr outsideWindow; continue} if {![dict exists $counts $pool]} { if {[dict size $counts]>=16} {continue} dict set counts $pool [lrepeat $slots 0] dict set reportedSuppressed $pool [lrepeat $slots 0] dict set occurrenceCounts $pool [lrepeat $slots 0] } set index [expr {int(($at-$from)/$bucket)}] set series [dict get $counts $pool] lset series $index [expr {[lindex $series $index]+1}] dict set counts $pool $series incr matched if {$severity eq "Warning"} {incr warnings} set occurrences [dict get $occurrenceCounts $pool] lset occurrences $index [expr {[lindex $occurrences $index]+1}] if {$suppressed>0} { # The 60-second bound is established by the new native # pool-full reporter. Older rate-limited notices have no # established occurrence bound and remain unallocated. set bounded [expr {$suppressionKind eq "pool-full events since last report"}] set windowEnd [expr {$previous eq "" ? "" : ($bounded ? min($previous+60,$at) : $at)}] set assigned -1 if {$bounded && $previous ne "" && $previous>=$from && $windowEnd<=$to && $windowEnd>$previous} { set firstBucket [expr {int(($previous-$from)/$bucket)}] # Log stamps have second resolution. Treat the end # second as possible, so a boundary is not guessed. set lastBucket [expr {int(($windowEnd-$from)/$bucket)}] if {$firstBucket==$lastBucket} { set assigned $firstBucket lset occurrences $assigned [expr {[lindex $occurrences $assigned]+$suppressed}] incr attributedSuppressed $suppressed } } if {$assigned<0} {incr unallocatedSuppressed $suppressed} lappend occurrenceWindows [list pool string $pool reportedAt number $at from [expr {$previous eq "" ? "null" : "number"}] $previous to [expr {$previous eq "" ? "null" : "number"}] $windowEnd suppressed number $suppressed assignedBucket [expr {$assigned<0 ? "null" : "number"}] [expr {$assigned<0 ? "" : $assigned}] kind string $suppressionKind] } dict set occurrenceCounts $pool $occurrences set repeats [dict get $reportedSuppressed $pool] lset repeats $index [expr {[lindex $repeats $index]+$suppressed}] dict set reportedSuppressed $pool $repeats if {![dict exists $suppressionPeaks $pool] || $suppressed>[dict get $suppressionPeaks $pool suppressed]} { dict set suppressionPeaks $pool [dict create at $at severity $severity waiting $waiting current $current suppressed $suppressed affected [expr {$suppressed+1}] previous $previous] } # Retain the strongest logged notice per pool and bucket. The # suppressed value is context since its preceding notice, not # a count assigned to this bucket. set key [list $pool $index] if {![dict exists $strongest $key] || $suppressed>[dict get $strongest $key suppressed]} { dict set strongest $key [dict create at $at pool $pool severity $severity waiting $waiting idle $idle current $current suppressed $suppressed affected [expr {$suppressed+1}] previous $previous] } } } finally {close $channel} if {[catch {file stat $path after}] || $before(dev) ne $after(dev) || $before(ino) ne $after(ino)} { return {available boolean false reason string current-system-log-rotated-during-scan} } if {$after(size)<$size} { return {available boolean false reason string current-system-log-truncated-during-scan} } set poolFields {} dict for {pool values} $counts { set array {} set index 0 foreach value $values {lappend array $index number $value; incr index} lappend poolFields $pool array $array } set suppressedFields {} set affectedFields {} set occurrenceFields {} dict for {pool values} $reportedSuppressed { set array {} set affectedArray {} set index 0 set physical [dict get $counts $pool] foreach value $values { lappend array $index number $value lappend affectedArray $index number [expr {$value+[lindex $physical $index]}] incr index } lappend suppressedFields $pool array $array lappend affectedFields $pool array $affectedArray } dict for {pool values} $occurrenceCounts { set array {} set index 0 foreach value $values {lappend array $index number $value; incr index} lappend occurrenceFields $pool array $array } set windowFields {} set windowIndex 0 foreach window [lrange [lsort -decreasing -integer -index 14 $occurrenceWindows] 0 63] { lappend windowFields $windowIndex object $window incr windowIndex } set peakFields {} dict for {pool peak} $suppressionPeaks { set previous [dict get $peak previous] lappend peakFields $pool object [list at number [dict get $peak at] severity string [dict get $peak severity] waiting number [dict get $peak waiting] current number [dict get $peak current] suppressedSincePrevious number [dict get $peak suppressed] affectedRequestsSincePrevious number [dict get $peak affected] previousReportAt [expr {$previous eq "" ? "null" : "number"}] $previous intervalSeconds [expr {$previous eq "" ? "null" : "number"}] [expr {$previous eq "" ? "" : [dict get $peak at]-$previous}]] } set eventFields {} set eventIndex 0 set ordered {} dict for {key event} $strongest { lappend ordered [list [dict get $event at] $event] } foreach entry [lsort -real -index 0 $ordered] { set event [lindex $entry 1] set detail [list at number [dict get $event at] pool string [dict get $event pool] severity string [dict get $event severity] waiting number [dict get $event waiting] idle number [dict get $event idle] current number [dict get $event current] suppressedSincePrevious number [dict get $event suppressed] affectedRequestsSincePrevious number [dict get $event affected]] set previous [dict get $event previous] lappend detail previousReportAt [expr {$previous eq "" ? "null" : "number"}] $previous lappend eventFields $eventIndex object $detail incr eventIndex } return [list available boolean true from number $from to number $to bucketSeconds number $bucket pools object $poolFields reportedSuppressedAtReport object $suppressedFields affectedRequestsReportedAtReport object $affectedFields affectedRequestsByOccurrence object $occurrenceFields suppressedOccurrenceWindows array $windowFields occurrenceCoverage object [list attributedSuppressed number $attributedSuppressed unallocatedSuppressed number $unallocatedSuppressed omittedWindows number [expr {max(0,[llength $occurrenceWindows]-64)}]] suppressionHighlights object $peakFields representativeEvents array $eventFields matchedEvents number $matched warningEvents number $warnings scannedBytes number [expr {$size-$low}] examinedLines number $examined candidateLines number $candidates parsedEventLines number $parsed unparsedCandidateExample [expr {$unparsedExample eq "" ? "null" : "string"}] $unparsedExample otherServerEvents number $otherServer invalidTimestamps number $invalidTimestamps outsideWindowEvents number $outsideWindow scanBudgetBytes number $scanBudget unreadEarlierBytes number $low currentFileOnly boolean true coverageLimited boolean [expr {$low>0}] limitations string {pools counts physical rate-limited Notice or Warning records at their logged times. Each suppressed repeat is a distinct request's first unsuccessful queue attempt; affectedRequestsSincePrevious adds the one request that produced the logged event. This counts requests affected by a full pool, including ones later served; it is neither simultaneous waiting nor failed requests nor distinct clients. These are report-backed counts, not a complete episode total: suppressed requests after the final logged event may never be flushed to the log. affectedRequestsByOccurrence places a suppressed count in a bucket only when its whole 60-second window after a known same-process previous report fits that bucket; occurrenceCoverage.unallocatedSuppressed is omitted from that series and must be reported separately. The bound is established only for the new native pool-full events; older rate-limited notices stay unallocated. suppressedOccurrenceWindows gives bounded timing for the new events, not individual arrival times. affectedRequestsReportedAtReport retains report-time accounting for audit and is not an occurrence-time series. A zero does not establish that the pool never filled: the current file may have rotated, earlier bytes may be unread, and repeated events are suppressed. One representative event per pool and bucket is retained.}]XQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)