WIP timeout handling
This commit is contained in:
@@ -5,7 +5,6 @@ use super::proto::CaMsgTy;
|
||||
use super::proto::CaProto;
|
||||
use super::store::DataStore;
|
||||
use super::ExtraInsertsConf;
|
||||
use super::IngestCommons;
|
||||
use crate::bsread::ChannelDescDecoded;
|
||||
use crate::ca::proto::CreateChan;
|
||||
use crate::ca::proto::EventAdd;
|
||||
@@ -392,8 +391,6 @@ pub struct CaConn {
|
||||
conn_backoff: f32,
|
||||
conn_backoff_beg: f32,
|
||||
inserts_counter: u64,
|
||||
#[allow(unused)]
|
||||
ingest_commons: Arc<IngestCommons>,
|
||||
extra_inserts_conf: ExtraInsertsConf,
|
||||
}
|
||||
|
||||
@@ -406,7 +403,6 @@ impl CaConn {
|
||||
insert_item_sender: CommonInsertItemQueueSender,
|
||||
array_truncate: usize,
|
||||
insert_queue_max: usize,
|
||||
ingest_commons: Arc<IngestCommons>,
|
||||
) -> Self {
|
||||
let (cq_tx, cq_rx) = async_channel::bounded(32);
|
||||
Self {
|
||||
@@ -437,7 +433,6 @@ impl CaConn {
|
||||
conn_backoff: 0.02,
|
||||
conn_backoff_beg: 0.02,
|
||||
inserts_counter: 0,
|
||||
ingest_commons,
|
||||
extra_inserts_conf: ExtraInsertsConf::new(),
|
||||
}
|
||||
}
|
||||
@@ -671,7 +666,11 @@ impl CaConn {
|
||||
self.stats.inserts_queue_push_inc();
|
||||
self.insert_item_send_fut = None;
|
||||
}
|
||||
Ready(Err(_)) => break Ready(Err(Error::with_msg_no_trace(format!("can not send the item")))),
|
||||
Ready(Err(e)) => {
|
||||
self.insert_item_send_fut = None;
|
||||
error!("handle_insert_futs can not send item {e}");
|
||||
break Ready(Err(Error::with_msg_no_trace(format!("can not send the item"))));
|
||||
}
|
||||
Pending => {
|
||||
if false {
|
||||
// TODO test this case.
|
||||
@@ -985,7 +984,10 @@ impl CaConn {
|
||||
fn handle_event_add_res(&mut self, ev: proto::EventAddRes, tsnow: Instant) -> Result<(), Error> {
|
||||
// TODO handle subid-not-found which can also be peer error:
|
||||
let cid = *self.cid_by_subid.get(&ev.subid).unwrap();
|
||||
// TODO get rid of the string clone when I don't want the log output any longer:
|
||||
if true {
|
||||
let name = self.name_by_cid(cid);
|
||||
info!("event {name:?} {ev:?}");
|
||||
}
|
||||
// TODO handle not-found error:
|
||||
let mut series_2 = None;
|
||||
let ch_s = self.channels.get_mut(&cid).unwrap();
|
||||
|
||||
@@ -89,7 +89,6 @@ impl CaConnSet {
|
||||
insert_queue_max: usize,
|
||||
insert_item_queue_sender: CommonInsertItemQueueSender,
|
||||
data_store: Arc<DataStore>,
|
||||
ingest_commons: Arc<IngestCommons>,
|
||||
with_channels: Vec<String>,
|
||||
) -> Result<(), Error> {
|
||||
info!("create new CaConn {:?}", addr);
|
||||
@@ -102,7 +101,6 @@ impl CaConnSet {
|
||||
insert_item_queue_sender,
|
||||
array_truncate,
|
||||
insert_queue_max,
|
||||
ingest_commons,
|
||||
);
|
||||
for ch in with_channels {
|
||||
conn.channel_add(ch);
|
||||
@@ -273,7 +271,6 @@ impl CaConnSet {
|
||||
200,
|
||||
ingest_commons.insert_item_queue.sender().await,
|
||||
ingest_commons.data_store.clone(),
|
||||
ingest_commons.clone(),
|
||||
vec![channel_name],
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::ca::proto::{CaMsg, CaMsgTy, HeadInfo};
|
||||
use err::Error;
|
||||
use futures_util::{FutureExt, Stream};
|
||||
use futures_util::{Future, FutureExt, Stream};
|
||||
use libc::c_int;
|
||||
use log::*;
|
||||
use std::collections::{BTreeMap, VecDeque};
|
||||
@@ -69,6 +69,7 @@ pub struct FindIocStream {
|
||||
bids_timed_out: BTreeMap<BatchId, ()>,
|
||||
sids_done: BTreeMap<SearchId, ()>,
|
||||
result_for_done_sid_count: u64,
|
||||
sleeper: Pin<Box<dyn Future<Output = ()> + Send>>,
|
||||
}
|
||||
|
||||
impl FindIocStream {
|
||||
@@ -94,6 +95,7 @@ impl FindIocStream {
|
||||
in_flight_max: 20,
|
||||
channels_per_batch: 10,
|
||||
batch_run_max: Duration::from_millis(2500),
|
||||
sleeper: Box::pin(tokio::time::sleep(Duration::from_millis(500))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,7 +576,13 @@ impl Stream for FindIocStream {
|
||||
continue;
|
||||
} else {
|
||||
if self.channels_input.is_empty() && self.in_flight.is_empty() && self.out_queue.is_empty() {
|
||||
Ready(None)
|
||||
match self.sleeper.poll_unpin(cx) {
|
||||
Ready(_) => {
|
||||
self.sleeper = Box::pin(tokio::time::sleep(Duration::from_millis(500)));
|
||||
continue;
|
||||
}
|
||||
Pending => Pending,
|
||||
}
|
||||
} else {
|
||||
Pending
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user