* refactor(server): split internode dispatch scaffold
* test(server): cover internode dispatch prefix split
* refactor(server): name internode stack boundaries
* perf(server): skip internode request logging layer
* perf(server): skip internode trace layer
* perf(server): use lite internode request context
* feat(metrics): track internode rpc duration
* feat(ecstore): add put object stage summary logs
* test(metrics): update internode descriptor expectations
* fix(server): tighten internode path matching
* fix(pr): address review follow-up comments
* style(ecstore): simplify commit tail duration field
* refactor(ecstore): group put stage summary fields
* refactor(ecstore): inline put stage summary log
* fix(s3): return storage class for object attributes
* merge: sync latest main and resolve object attributes conflict
* fmt
* fix(server): remove duplicate rpc imports
* build(deps): bump memmap2 for RUSTSEC-2026-0186
* fix(s3select): align object_store with datafusion
* chore(deps): prune workspace dependencies
* perf(fuzz): optimize CI runtime with build/run split and matrix parallelization
Separate fuzz harness compilation from execution to eliminate redundant
builds across targets. Introduce matrix-based parallel execution for
PR smoke and nightly fuzz jobs.
Changes:
- Split CI workflow into `fuzz-build` (compile once) and matrix run jobs
(`pr-fuzz-smoke`, `nightly-fuzz-corpus`) that execute targets in parallel
- Add `BUILD_ONLY` mode to run_ci_targets.sh / run_nightly_targets.sh
- Add run_single_target.sh for matrix jobs (no build phase)
- Optimize `local_metadata` fuzz target: reduce prefix iterations from
8-10 (4 functions each) to 5 critical prefixes (parser-only), cutting
per-iteration cost by ~3-5x
- Move archive path validation (`validate_extract_relative_path`,
`normalize_extract_entry_key`) from `rustfs` to `rustfs-utils::path`,
eliminating `rustfs` binary crate dependency from fuzz harness
- Remove `rustfs` from fuzz/Cargo.toml (drops significant transitive deps)
- Add unit tests for archive path validation in rustfs-utils
- Update fuzz/README.md with new workflow and script documentation
Expected CI improvement: PR smoke wall-clock from ~120min (frequent
timeout) to ~40min; nightly from ~180min to ~60min.
* refactor(fuzz): consolidate scripts and fix prefix test alignment
Replace three duplicated shell scripts (run_ci_targets.sh,
run_nightly_targets.sh, run_single_target.sh) with a single
parameterized run.sh that supports BUILD_ONLY, SKIP_BUILD, and
MAX_TOTAL_TIME environment variables.
Fix local_metadata fuzz target prefix testing: replace always-true
'len > 0' guard with lengths aligned to xl.meta binary layout
(4/5/8/12 bytes for magic+version+header fields). Remove redundant
empty-slice test.
Hoist RUSTFLAGS to workflow top-level env to eliminate per-job
duplication. Update README with unified script documentation.
Net: -118 lines, zero functionality loss.
* perf(fuzz): optimize CI runtime with build/run split and matrix parallelization
Restructure fuzz CI workflow to eliminate redundant compilation and
run targets in parallel via matrix strategy.
Workflow changes:
- Split into fuzz-build (compile once) and matrix run jobs
- PR smoke: 3 targets parallel, 60s each, timeout 30min (was 120min)
- Nightly: 3 targets parallel, 300s each, timeout 60min (was 180min)
- Pass compiled harness via actions/artifact between jobs
- Hoist RUSTFLAGS to workflow top-level env
Script consolidation:
- Replace 3 duplicated scripts with single parameterized run.sh
- Supports BUILD_ONLY, SKIP_BUILD, MAX_TOTAL_TIME env vars
Target optimizations:
- Remove rustfs binary crate from fuzz dependencies (was pulling
979 transitive deps); move archive path validation to rustfs-utils
- Optimize local_metadata: reduce prefix iterations from 8-10x4
calls to 5 prefixes with parser-only (no decompress), aligned
with xl.meta binary layout (4/5/8/12 bytes)
- Add unit tests for archive path validation in rustfs-utils
- Update fuzz/README.md with unified script documentation
Expected: PR smoke wall-clock from ~120min (frequent timeout)
to ~40min; nightly from ~180min to ~60min.
* fix(rpc): resolve internode metrics via app context
* fmt
* ci: speed up fuzz smoke artifact restore
---------
Signed-off-by: houseme <[email protected]>
181 lines
7.0 KiB
Rust
181 lines
7.0 KiB
Rust
// Copyright 2024 RustFS Team
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
use crate::query::Context;
|
|
use crate::{QueryError, QueryResult, object_store::EcObjectStore};
|
|
use datafusion::{
|
|
arrow::{
|
|
array::{Int32Array, StringArray},
|
|
datatypes::{DataType, Field, Schema},
|
|
record_batch::RecordBatch,
|
|
},
|
|
execution::{SessionStateBuilder, context::SessionState, runtime_env::RuntimeEnvBuilder},
|
|
object_store::{ObjectStore, ObjectStoreExt, memory::InMemory, path::Path},
|
|
parquet::arrow::ArrowWriter,
|
|
prelude::SessionContext,
|
|
};
|
|
use std::sync::Arc;
|
|
use tracing::error;
|
|
|
|
#[derive(Clone)]
|
|
pub struct SessionCtx {
|
|
_desc: Arc<SessionCtxDesc>,
|
|
inner: SessionState,
|
|
}
|
|
|
|
impl SessionCtx {
|
|
pub fn inner(&self) -> &SessionState {
|
|
&self.inner
|
|
}
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct SessionCtxDesc {
|
|
// maybe we need some info
|
|
}
|
|
|
|
#[derive(Default)]
|
|
pub struct SessionCtxFactory {
|
|
pub is_test: bool,
|
|
}
|
|
|
|
impl SessionCtxFactory {
|
|
pub async fn create_session_ctx(&self, context: &Context) -> QueryResult<SessionCtx> {
|
|
let df_session_ctx = self.build_df_session_context(context).await?;
|
|
|
|
Ok(SessionCtx {
|
|
_desc: Arc::new(SessionCtxDesc {}),
|
|
inner: df_session_ctx.state(),
|
|
})
|
|
}
|
|
|
|
async fn build_df_session_context(&self, context: &Context) -> QueryResult<SessionContext> {
|
|
let path = format!("s3://{}", context.input.bucket);
|
|
let store_url = url::Url::parse(&path).unwrap();
|
|
let rt = RuntimeEnvBuilder::new().build()?;
|
|
let df_session_state = SessionStateBuilder::new()
|
|
.with_runtime_env(Arc::new(rt))
|
|
.with_default_features();
|
|
|
|
let df_session_state = if self.is_test {
|
|
let store: Arc<dyn ObjectStore> = Arc::new(InMemory::new());
|
|
|
|
// Choose test data format based on what the request serialization specifies.
|
|
let data_bytes: Vec<u8> = if context.input.request.input_serialization.parquet.is_some() {
|
|
test_parquet_bytes()?
|
|
} else if context.input.request.input_serialization.json.is_some() {
|
|
// NDJSON: one JSON object per line — usable for both LINES and DOCUMENT
|
|
// requests (DOCUMENT inputs are converted to NDJSON by EcObjectStore, but
|
|
// in test mode we bypass EcObjectStore, so we put NDJSON here directly).
|
|
b"{\"id\":1,\"name\":\"Alice\",\"age\":25,\"department\":\"HR\",\"salary\":5000}\n\
|
|
{\"id\":2,\"name\":\"Bob\",\"age\":30,\"department\":\"IT\",\"salary\":6000}\n\
|
|
{\"id\":3,\"name\":\"Charlie\",\"age\":35,\"department\":\"Finance\",\"salary\":7000}\n\
|
|
{\"id\":4,\"name\":\"Diana\",\"age\":22,\"department\":\"Marketing\",\"salary\":4500}\n\
|
|
{\"id\":5,\"name\":\"Eve\",\"age\":28,\"department\":\"IT\",\"salary\":5500}\n\
|
|
{\"id\":6,\"name\":\"Frank\",\"age\":40,\"department\":\"Finance\",\"salary\":8000}\n\
|
|
{\"id\":7,\"name\":\"Grace\",\"age\":26,\"department\":\"HR\",\"salary\":5200}\n\
|
|
{\"id\":8,\"name\":\"Henry\",\"age\":32,\"department\":\"IT\",\"salary\":6200}\n\
|
|
{\"id\":9,\"name\":\"Ivy\",\"age\":24,\"department\":\"Marketing\",\"salary\":4800}\n\
|
|
{\"id\":10,\"name\":\"Jack\",\"age\":38,\"department\":\"Finance\",\"salary\":7500}\n"
|
|
.to_vec()
|
|
} else {
|
|
b"id,name,age,department,salary
|
|
1,Alice,25,HR,5000
|
|
2,Bob,30,IT,6000
|
|
3,Charlie,35,Finance,7000
|
|
4,Diana,22,Marketing,4500
|
|
5,Eve,28,IT,5500
|
|
6,Frank,40,Finance,8000
|
|
7,Grace,26,HR,5200
|
|
8,Henry,32,IT,6200
|
|
9,Ivy,24,Marketing,4800
|
|
10,Jack,38,Finance,7500"
|
|
.to_vec()
|
|
};
|
|
|
|
let path = Path::from(context.input.key.clone());
|
|
store.put(&path, data_bytes.into()).await.map_err(|e| {
|
|
error!("put data into memory failed: {}", e.to_string());
|
|
QueryError::StoreError { e: e.to_string() }
|
|
})?;
|
|
|
|
df_session_state.with_object_store(&store_url, store).build()
|
|
} else {
|
|
let store: EcObjectStore =
|
|
EcObjectStore::new(context.input.clone()).map_err(|_| QueryError::NotImplemented { err: String::new() })?;
|
|
df_session_state.with_object_store(&store_url, Arc::new(store)).build()
|
|
};
|
|
|
|
let df_session_ctx = SessionContext::new_with_state(df_session_state);
|
|
|
|
Ok(df_session_ctx)
|
|
}
|
|
}
|
|
|
|
fn test_parquet_bytes() -> QueryResult<Vec<u8>> {
|
|
let schema = Arc::new(Schema::new(vec![
|
|
Field::new("id", DataType::Int32, false),
|
|
Field::new("name", DataType::Utf8, false),
|
|
Field::new("age", DataType::Int32, false),
|
|
Field::new("department", DataType::Utf8, false),
|
|
Field::new("salary", DataType::Int32, false),
|
|
]));
|
|
let first_batch =
|
|
test_parquet_batch(Arc::clone(&schema), &[1, 2], &["Alice", "Bob"], &[25, 30], &["HR", "IT"], &[5000, 6000])?;
|
|
let second_batch = test_parquet_batch(
|
|
Arc::clone(&schema),
|
|
&[3, 4, 5],
|
|
&["Charlie", "Diana", "Eve"],
|
|
&[35, 22, 28],
|
|
&["Finance", "Marketing", "IT"],
|
|
&[7000, 4500, 5500],
|
|
)?;
|
|
|
|
let mut bytes = Vec::new();
|
|
{
|
|
let mut writer =
|
|
ArrowWriter::try_new(&mut bytes, schema, None).map_err(|e| QueryError::StoreError { e: e.to_string() })?;
|
|
writer
|
|
.write(&first_batch)
|
|
.map_err(|e| QueryError::StoreError { e: e.to_string() })?;
|
|
writer.flush().map_err(|e| QueryError::StoreError { e: e.to_string() })?;
|
|
writer
|
|
.write(&second_batch)
|
|
.map_err(|e| QueryError::StoreError { e: e.to_string() })?;
|
|
writer.close().map_err(|e| QueryError::StoreError { e: e.to_string() })?;
|
|
}
|
|
Ok(bytes)
|
|
}
|
|
|
|
fn test_parquet_batch(
|
|
schema: Arc<Schema>,
|
|
ids: &[i32],
|
|
names: &[&str],
|
|
ages: &[i32],
|
|
departments: &[&str],
|
|
salaries: &[i32],
|
|
) -> QueryResult<RecordBatch> {
|
|
RecordBatch::try_new(
|
|
schema,
|
|
vec![
|
|
Arc::new(Int32Array::from(ids.to_vec())),
|
|
Arc::new(StringArray::from(names.to_vec())),
|
|
Arc::new(Int32Array::from(ages.to_vec())),
|
|
Arc::new(StringArray::from(departments.to_vec())),
|
|
Arc::new(Int32Array::from(salaries.to_vec())),
|
|
],
|
|
)
|
|
.map_err(|e| QueryError::StoreError { e: e.to_string() })
|
|
}
|