-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(cubestore): Report a websocket peer that goes away as debug, not error #11786
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
Changes from all commits
665f691
48be719
f1a0ef4
e799245
880d836
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| use crate::files::write_tmp_file; | ||
| use crate::files::{serve_file, write_tmp_file}; | ||
| use crate::rows::{rows, NULL}; | ||
| use crate::SqlClient; | ||
| use async_compression::tokio::write::GzipEncoder; | ||
|
|
@@ -2469,8 +2469,15 @@ async fn create_table_with_csv_no_header_and_quotes( | |
| } | ||
|
|
||
| async fn create_table_with_url(service: Box<dyn SqlClient>) -> Result<(), CubeError> { | ||
| // TODO serve this data ourselves | ||
| let url = "https://data.wprdc.org/dataset/0b584c84-7e35-4f4d-a5a2-b01697470c0f/resource/e95dd941-8e47-4460-9bd8-1e51c194370b/download/bikepghpublic.csv"; | ||
| let mut csv = "Response ID,Start Date,End Date\n".to_string(); | ||
| for id in 0..813 { | ||
| csv += &format!("{},2020-01-01T00:00:00.000Z,2020-01-02T00:00:00.000Z\n", id); | ||
| } | ||
| // The body is held back because the query below has to run against a table | ||
| // whose import has not finished: only ready tables are visible to the | ||
| // planner. | ||
| let server = serve_file(csv, Duration::from_millis(500)).await?; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Serving the file ourselves is the right fix, and the assertion is more robust than it looks — if the 500 ms is probably enough in practice, but the window is a magic number that only the prose above explains. Releasing the body on a signal instead would remove the timing dependency entirely — have Not blocking — the failure mode is a re-run, not a wrong result. |
||
| let url = server.url("bikepghpublic.csv"); | ||
|
|
||
| service | ||
| .exec_query("CREATE SCHEMA IF NOT EXISTS foo") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4878,13 +4878,24 @@ mod tests { | |
| config.max_partition_split_threshold = 200; | ||
| config | ||
| }).start_test_worker(async move |_| { | ||
| let url = "https://data.wprdc.org/dataset/0b584c84-7e35-4f4d-a5a2-b01697470c0f/resource/e95dd941-8e47-4460-9bd8-1e51c194370b/download/bikepghpublic.csv"; | ||
| // The threshold is derived from the size of the location, | ||
| // not from its contents: see ImportServiceImpl::estimate_rows. | ||
| // Rows are padded so the estimate lands above | ||
| // max_partition_split_threshold per select worker, which is | ||
| // what makes the cap observable. | ||
| let path = env::temp_dir().join(format!("{}.csv", test_name)); | ||
| let padding = "x".repeat(256); | ||
| let mut csv = "Response ID,Start Date,End Date\n".to_string(); | ||
| for id in 0..813 { | ||
| csv += &format!("{},2020-01-01T00:00:00.000Z,{}\n", id, padding); | ||
| } | ||
|
Comment on lines
+4881
to
+4891
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The generated file is the right call, and the arithmetic checks out (232,440 bytes → 907 estimated rows → 453 per select worker, comfortably above the 200 cap). Two small things about how that arithmetic is expressed: The comment is 5 lines for 6 lines of code, and its second half restates what the constants below already do. The load-bearing fact is the first sentence — // estimate_rows only stats the location, it never reads it.
let rows = 813;
// One padded row is about one estimated row: estimate_rows divides by 256.
let padding = "x".repeat(256);makes the "813 rows / 2 workers > 200" chain visible without prose. Not blocking either way. |
||
| tokio::fs::write(&path, csv).await?; | ||
|
|
||
| service | ||
| .exec_query("CREATE SCHEMA IF NOT EXISTS foo") | ||
| .await?.collect().await?; | ||
|
|
||
| let create_table_sql = format!("CREATE TABLE foo.bikes (`Response ID` int, `Start Date` text, `End Date` text) LOCATION '{}'", url); | ||
| let create_table_sql = format!("CREATE TABLE foo.bikes (`Response ID` int, `Start Date` text, `End Date` text) LOCATION '{}'", path.to_string_lossy()); | ||
|
|
||
| service.exec_query(&create_table_sql).await?.collect().await?; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small things about the accept loop, neither blocking:
log::error!here fires on a benign disconnect too —Dropaborts only the accept task, so an in-flightserve_one_requestwhose peer went away (the test finished, the importer dropped the connection after a retry) writes to a closed socket and logs anerror. Given what this PR is about,debug!seems more consistent; nothing an operator or a CI reader can act on.while let Ok(..)exits the loop on the firstaccepterror, so a transient failure silently turns the server into a black hole and the test then fails as an import timeout rather than as "the server stopped".Err→continue(or abreakwith a log) would make that legible.Fix this →