nsmcp::AccessRecordPartitions method partitionOpen (protected)
<instance of nsmcp::AccessRecordPartitions> partitionOpen
Defined in /usr/local/ns/tcl/nsmcp/log-traffic-record-01-partitions.tcl
- Testcases:
- No testcase defined.
Source code: set stored [:stateGet partitionInterval 0] if {$stored!=${:partitionInterval} && ($stored>0 || ${:partitionInterval}>0)} { if {$stored>0} { error "record-store-partition-reset-required" } if {${:mode} ne "writer"} { error "record-store-partition-reset-required" } ${:db} transaction { # Check under the writer lock; never convert populated caches. if {[${:db} scalar {SELECT EXISTS(SELECT 1 FROM main.rows LIMIT 1) OR EXISTS(SELECT 1 FROM main.files LIMIT 1)}]} { error "record-store-partition-reset-required" } ${:db} execute { ALTER TABLE main.rows RENAME TO row_template; CREATE TABLE main.partitions( start INTEGER PRIMARY KEY,stop INTEGER NOT NULL,name TEXT UNIQUE NOT NULL, n INTEGER NOT NULL DEFAULT 0,first REAL,last REAL) } ${:db} execute {UPDATE main.meta SET version=4} :statePut partitionInterval ${:partitionInterval} :statePut rollupsReady 1 set bootstrap [:dict getdef ${:settings} bootstrapSeconds 172800] :statePut bootstrapFrom [expr {[clock seconds]-min($bootstrap,[dict get ${:settings} retention])}] :partitionView } } if {${:partitionInterval}>0} { set sql [${:db} scalar {SELECT sql FROM main.sqlite_schema WHERE name='row_template' AND type='table'}] if {$sql eq {} || [string first ( $sql]<0} { error "record-store-partition-reset-required" } set :partitionDDL [string range $sql [string first ( $sql] end] file stat ${:path} peerIndexFile set peerIndexKey [list ${:path} $peerIndexFile(dev) $peerIndexFile(ino)] if {${:mode} eq "writer" && ![nsv_exists nsmcp:peer-history-index:[ns_info server] $peerIndexKey]} { # Only index partitions that a recent warning history can read. # Older retained partitions remain untouched. set cutoff [expr {[clock seconds]-86400}] foreach row [${:db} execute {SELECT name FROM main.partitions WHERE stop>:cutoff ORDER BY start}] { set name [dict get $row name] if {![regexp {^p_[0-9]+$} $name]} {error "record-store-invalid-partition"} ${:db} execute "CREATE INDEX IF NOT EXISTS main.${name}_peer_time ON ${name}(peer,t)" } nsv_set nsmcp:peer-history-index:[ns_info server] $peerIndexKey 1 } }XQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)