Skip to content

Commit 50836e0

Browse files
committed
Merge remote-tracking branch 'root/main' into feat_refactor_tag
2 parents 04f09e2 + 28bb20b commit 50836e0

517 files changed

Lines changed: 16130 additions & 11170 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/artifact_meta_container_failure/action.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,25 @@ runs:
1111
shell: bash
1212
run: |
1313
mkdir -p logs
14+
15+
echo "=== Collecting k8s diagnostics ==="
16+
17+
# Pod status and events
18+
kubectl get pods -n databend -o wide > logs/pods-status.txt 2>&1 || true
19+
kubectl describe pods -n databend > logs/pods-describe.txt 2>&1 || true
20+
kubectl get events -n databend --sort-by='.lastTimestamp' > logs/events.txt 2>&1 || true
21+
22+
# Chaos mesh resources
23+
kubectl get iochaos -n databend -o yaml > logs/iochaos.txt 2>&1 || true
24+
25+
# Container logs (kubectl logs) and file logs
1426
for name in "test-databend-meta-0" "test-databend-meta-1" "test-databend-meta-2" "databend-metaverifier"
1527
do
16-
echo "cat logs of $name"
17-
kubectl exec -i $name -n databend -- /cat-logs.sh > logs/$name.log
28+
echo "collecting logs of $name"
29+
kubectl logs "$name" -n databend --tail=2000 > "logs/${name}-kubectl.log" 2>&1 || true
30+
kubectl exec -i "$name" -n databend -- /cat-logs.sh > "logs/${name}-file.log" 2>&1 || true
1831
done
32+
1933
tar -zcf logs/failure-${{ inputs.name }}.tar.gz logs/*
2034
- uses: actions/upload-artifact@v4
2135
with:

.github/actions/io_delay_chaos/action.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,3 @@ runs:
77
shell: bash
88
run: |
99
./scripts/ci/meta-chaos/ci-io-delay-meta-test.sh
10-
11-
- name: Upload failure
12-
if: failure()
13-
uses: ./.github/actions/artifact_meta_container_failure
14-
with:
15-
name: meta-io-delay-chaos

.github/workflows/meta.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,8 @@ jobs:
7979
artifacts: meta,metactl,metaverifier
8080
- uses: ./.github/actions/io_delay_chaos
8181
timeout-minutes: 20
82+
- name: Upload failure artifacts
83+
if: failure() || cancelled()
84+
uses: ./.github/actions/artifact_meta_container_failure
85+
with:
86+
name: meta-io-delay-chaos

.github/workflows/release.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ jobs:
9696
run: |
9797
case "${{ steps.bump.outputs.type }}" in
9898
nightly)
99-
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --notes-file /tmp/release_notes.md --prerelease --draft
99+
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --notes-file /tmp/release_notes.md --title ${{ steps.bump.outputs.tag }} --prerelease --draft
100100
;;
101101
stable)
102-
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --notes-file /tmp/release_notes.md --latest --draft
102+
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --notes-file /tmp/release_notes.md --title ${{ steps.bump.outputs.tag }} --latest --draft
103103
;;
104104
patch)
105-
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --notes-file /tmp/release_notes.md --prerelease --draft
105+
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --notes-file /tmp/release_notes.md --title ${{ steps.bump.outputs.tag }} --prerelease --draft
106106
;;
107107
*)
108108
echo "Invalid release type: ${{ steps.bump.outputs.type }}"
@@ -667,6 +667,11 @@ jobs:
667667
artifacts: meta,metactl,metaverifier
668668
- uses: ./.github/actions/io_delay_chaos
669669
timeout-minutes: 20
670+
- name: Upload failure artifacts
671+
if: failure() || cancelled()
672+
uses: ./.github/actions/artifact_meta_container_failure
673+
with:
674+
name: meta-io-delay-chaos
670675
- name: Notify failure
671676
if: failure()
672677
uses: actions/github-script@v7

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ target/
2626
# profile
2727
flamegraph.*
2828
perf.*
29+
!perf.rs
2930

3031
# tests
3132
*.stderr

Cargo.lock

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ databend-common-catalog = { path = "src/query/catalog" }
7373
databend-common-cloud-control = { path = "src/common/cloud_control" }
7474
databend-common-codegen = { path = "src/query/codegen" }
7575
databend-common-column = { path = "src/common/column" }
76+
databend-common-component = { path = "src/query/common/component" }
7677
databend-common-compress = { path = "src/common/compress" }
7778
databend-common-config = { path = "src/query/config" }
7879
databend-common-datavalues = { path = "src/query/datavalues" }

src/common/base/src/runtime/runtime_tracker.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ impl CaptureLogSettings {
135135

136136
pub struct TrackingPayload {
137137
pub query_id: Option<String>,
138+
pub warehouse_id: Option<String>,
138139
pub profile: Option<Arc<Profile>>,
139140
pub mem_stat: Option<Arc<MemStat>>,
140141
pub metrics: Option<Arc<ScopedRegistry>>,
@@ -204,6 +205,7 @@ impl Clone for TrackingPayload {
204205
fn clone(&self) -> Self {
205206
TrackingPayload {
206207
query_id: self.query_id.clone(),
208+
warehouse_id: self.warehouse_id.clone(),
207209
profile: self.profile.clone(),
208210
mem_stat: self.mem_stat.clone(),
209211
metrics: self.metrics.clone(),
@@ -291,6 +293,7 @@ impl ThreadTracker {
291293
metrics: None,
292294
mem_stat: None,
293295
query_id: None,
296+
warehouse_id: None,
294297
capture_log_settings: None,
295298
time_series_profile: None,
296299
local_time_series_profile: None,
@@ -410,6 +413,19 @@ impl ThreadTracker {
410413
.unwrap_or(None)
411414
}
412415

416+
pub fn warehouse_id() -> Option<&'static String> {
417+
TRACKER
418+
.try_with(|tracker| {
419+
tracker
420+
.borrow()
421+
.payload
422+
.warehouse_id
423+
.as_ref()
424+
.map(|warehouse_id| unsafe { &*(warehouse_id as *const String) })
425+
})
426+
.unwrap_or(None)
427+
}
428+
413429
pub fn capture_log_settings() -> Option<&'static Arc<CaptureLogSettings>> {
414430
TRACKER
415431
.try_with(|tracker| {

src/common/statistics/src/histogram.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,21 @@ pub const DEFAULT_HISTOGRAM_BUCKETS: usize = 100;
3838
pub struct Histogram {
3939
pub accuracy: bool,
4040
pub buckets: Vec<HistogramBucket>,
41+
/// Bucket width: (max - min) / num_buckets.
42+
/// Only set when accuracy == false (generated from NDV + min/max).
43+
/// Used to detect range distortion caused by outlier values inflating min/max.
44+
/// A very large bucket_width means linear interpolation within buckets is unreliable.
45+
#[serde(default)]
46+
pub avg_spacing: Option<f64>,
4147
}
4248

4349
impl Histogram {
4450
pub fn new(buckets: Vec<HistogramBucket>, accuracy: bool) -> Self {
45-
Self { accuracy, buckets }
51+
Self {
52+
accuracy,
53+
buckets,
54+
avg_spacing: None,
55+
}
4656
}
4757

4858
/// Get number of buckets

src/common/tracing/src/remote_log.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ use crate::loggers::collect_kvs;
5858
pub struct RemoteLog {
5959
cluster_id: String,
6060
node_id: String,
61-
warehouse_id: Option<String>,
6261
buffer: Arc<LogBuffer>,
6362
}
6463

@@ -113,13 +112,9 @@ impl RemoteLog {
113112
let node_id = labels.get("node_id").cloned().unwrap_or_default();
114113
let rt = Runtime::with_worker_threads(2, Some("remote-log-writer".to_string()))?;
115114
let (tx, rx) = bounded(1);
116-
// warehouse_id need to be specified after `create warehouse`
117-
// TODO: inject warehouse_id like query_id
118-
let warehouse_id = None;
119115
let remote_log = RemoteLog {
120116
cluster_id: labels.get("cluster_id").cloned().unwrap_or_default(),
121117
node_id: node_id.clone(),
122-
warehouse_id,
123118
buffer: Arc::new(LogBuffer::new(tx.clone(), interval as u64)),
124119
};
125120
rt.spawn(async move { RemoteLog::work(rx, &stage_name).await });
@@ -209,6 +204,7 @@ impl RemoteLog {
209204
pub fn prepare_log_element(&self, record: &Record) -> RemoteLogElement {
210205
let timestamp = Timestamp::now().as_microsecond();
211206
let query_id = ThreadTracker::query_id().cloned();
207+
let warehouse_id = ThreadTracker::warehouse_id().cloned();
212208
let target = record.target().to_string();
213209
let message = record.args().to_string();
214210
let fields = Map::from_iter(collect_kvs(record.key_values()));
@@ -232,7 +228,7 @@ impl RemoteLog {
232228
target,
233229
cluster_id: self.cluster_id.clone(),
234230
node_id: self.node_id.clone(),
235-
warehouse_id: self.warehouse_id.clone(),
231+
warehouse_id,
236232
query_id,
237233
log_level,
238234
message,

0 commit comments

Comments
 (0)