Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cloud): add clean timeout for matchmaker logs #942

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion infra/tf/vector/vector.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ resource "helm_release" "vector" {
ca_file = "/usr/local/share/ca-certificates/clickhouse-ca.crt"
} : {}
batch = {
timeout_secs = 5.0
# Speed up for realtime-ish logs
timeout_secs = 1.0
}
}

Expand Down
7 changes: 7 additions & 0 deletions lib/util/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ pub mod sort;
pub mod timestamp;
pub mod uuid;

pub mod watch {
/// Represented in seconds.
///
/// See docs/infrastructure/TIMEOUTS.md for reasoning.
pub const DEFAULT_TIMEOUT: u64 = 40 * 1000;
}

#[cfg(feature = "serde")]
pub mod serde {
use aws_smithy_types::Document;
Expand Down
7 changes: 1 addition & 6 deletions lib/util/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ use syn::{
Expr, Ident, Result, Token,
};

/// Represented in seconds.
///
/// See docs/infrastructure/TIMEOUTS.md for reasoning.
const DEFAULT_TIMEOUT: u64 = 40 * 1000;

mod kw {
syn::custom_keyword!(JITTER);
}
Expand Down Expand Up @@ -172,7 +167,7 @@ pub fn select_with_timeout(item: TokenStream) -> TokenStream {
let (timeout, timeout_scale) = data
.timeout
.map(|(timeout, timeout_scale)| (timeout.to_token_stream(), timeout_scale))
.unwrap_or((quote! { #DEFAULT_TIMEOUT }, 1));
.unwrap_or((quote! { util::watch::DEFAULT_TIMEOUT }, 1));
let returning = data.returning.map_or_else(
|| {
quote! {Default::default()}
Expand Down
5 changes: 5 additions & 0 deletions svc/api/cloud/src/route/games/matchmaker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ pub async fn get_lobby_logs(
break logs_res;
}

// Timeout cleanly
if query_start.elapsed().as_millis() > util::watch::DEFAULT_TIMEOUT as u128 {
break job_log::read::Response { entries: Vec::new() };
}

// Throttle request
//
// We don't use `tokio::time::interval` because if the request takes longer than 500
Expand Down
Loading