|
1 | 1 | //! Utilities to keep moving statistics about queries
|
2 | 2 |
|
3 | 3 | use rand::{prelude::Rng, thread_rng};
|
4 |
| -use std::collections::HashMap; |
| 4 | +use std::collections::{HashMap, HashSet}; |
5 | 5 | use std::env;
|
6 | 6 | use std::str::FromStr;
|
7 | 7 | use std::sync::{Arc, RwLock};
|
@@ -142,22 +142,22 @@ pub struct LoadManager {
|
142 | 142 | store_wait_stats: PoolWaitStats,
|
143 | 143 | /// List of query shapes that have been statically blocked through
|
144 | 144 | /// configuration
|
145 |
| - blocked_queries: Vec<u64>, |
| 145 | + blocked_queries: HashSet<u64>, |
146 | 146 | /// List of query shapes that have caused more than `JAIL_THRESHOLD`
|
147 | 147 | /// proportion of the work while the system was overloaded. Currently,
|
148 | 148 | /// there is no way for a query to get out of jail other than
|
149 | 149 | /// restarting the process
|
150 |
| - jailed_queries: RwLock<Vec<u64>>, |
| 150 | + jailed_queries: RwLock<HashSet<u64>>, |
151 | 151 | kill_state: RwLock<KillState>,
|
152 | 152 | }
|
153 | 153 |
|
154 | 154 | impl LoadManager {
|
155 |
| - pub fn new(store_wait_stats: PoolWaitStats, blocked_queries: Vec<u64>) -> Self { |
| 155 | + pub fn new(store_wait_stats: PoolWaitStats, blocked_queries: HashSet<u64>) -> Self { |
156 | 156 | Self {
|
157 | 157 | effort: QueryEffort::default(),
|
158 | 158 | store_wait_stats,
|
159 | 159 | blocked_queries,
|
160 |
| - jailed_queries: RwLock::new(Vec::new()), |
| 160 | + jailed_queries: RwLock::new(HashSet::new()), |
161 | 161 | kill_state: RwLock::new(KillState::new()),
|
162 | 162 | }
|
163 | 163 | }
|
@@ -250,7 +250,7 @@ impl LoadManager {
|
250 | 250 | if known_query && query_effort / total_effort > *JAIL_THRESHOLD {
|
251 | 251 | // Any single query that causes at least JAIL_THRESHOLD of the
|
252 | 252 | // effort in an overload situation gets killed
|
253 |
| - self.jailed_queries.write().unwrap().push(shape_hash); |
| 253 | + self.jailed_queries.write().unwrap().insert(shape_hash); |
254 | 254 | return true;
|
255 | 255 | }
|
256 | 256 |
|
|
0 commit comments