// dbClearStaleNodes will clear the console pod id for any node that has a timestamp
// older than the duration provided here. Any error(s) will be returned.
dbClearStaleNodes will clear the console pod id for any node that has a timestamp
older than the duration provided here. Any error(s) will be returned.
// dbClearStaleNodes will clear the console pod id for any node that has a timestamp // older than the duration provided here . Any error ( s ) will be returned .
func dbClearStaleNodes(duration int) (rowsAffected int64, err error) {
	mu.Lock()
	defer mu.Unlock()
	sqlStmt := `
		update ownership set console_pod_id=NULL, heartbeat=NULL
		where heartbeat < now()::timestamp - INTERVAL '%d minute'
	`
	sqlStmt = fmt.Sprintf(sqlStmt, duration) 
	result, err := DB.Exec(sqlStmt)
	rowsAffected = 0
	if err != nil {
		errMsg := fmt.Sprintf("WARN: dbClearStaleNodes: There is an UPDATE error: %s", err)
		log.Printf(errMsg)
		err = errors.New(errMsg)
	}
	if result != nil {
		rowsAffected, _ = result.RowsAffected()
		debugLog.Println(fmt.Sprintf("result.RowsAffected %d", rowsAffected))
	}
	return rowsAffected, err
}
func dbClearStaleNodes ( duration int ) ( rowsAffected int64 , err error ) { mu . Lock ( ) defer mu . Unlock ( ) sqlStmt := `
		update ownership set console_pod_id=NULL, heartbeat=NULL
		where heartbeat < now()::timestamp - INTERVAL '%d minute'
	` sqlStmt = fmt . Sprintf ( sqlStmt , duration ) result , err := DB . Exec ( sqlStmt ) rowsAffected = 0 if err != nil { errMsg := fmt . Sprintf ( " " , err ) log . Printf ( errMsg ) err = errors . New ( errMsg ) } if result != nil { rowsAffected , _ = result . RowsAffected ( ) debugLog . Println ( fmt . Sprintf ( " " , rowsAffected ) ) } return rowsAffected , err }
dbClearStaleNodes will clear the console pod id for any node that has a timestamp
older than the duration provided here.
dbClearStaleNodes will clear the console pod id for any node that has a timestamp older than the duration provided here .
// DB.exec will not substitute // On an update operation RowsAffected will be the count acually updated.