Skip to content

Commit ba546cb

Browse files
authored
Merge branch 'main' into fix/ISSUE-7684
2 parents 80a0161 + f02aa84 commit ba546cb

File tree

31 files changed

+528
-244
lines changed

31 files changed

+528
-244
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: "Test Stateful Cluster Linux"
2+
description: "Running stateful tests in cluster mode"
3+
inputs:
4+
profile:
5+
description: "The profile for this test"
6+
required: true
7+
default: "debug"
8+
target:
9+
description: ""
10+
required: true
11+
default: "x86_64-unknown-linux-gnu"
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Download artifact
16+
uses: ./.github/actions/artifact_download
17+
with:
18+
profile: ${{ inputs.profile }}
19+
sha: ${{ github.sha }}
20+
target: ${{ inputs.target }}
21+
22+
- name: Minio Setup for (ubuntu-latest only)
23+
shell: bash
24+
run: |
25+
docker run -d -p 9900:9000 --name minio \
26+
-e "MINIO_ACCESS_KEY=minioadmin" \
27+
-e "MINIO_SECRET_KEY=minioadmin" \
28+
-v /tmp/data:/data \
29+
-v /tmp/config:/root/.minio \
30+
minio/minio server /data
31+
32+
export AWS_ACCESS_KEY_ID=minioadmin
33+
export AWS_SECRET_ACCESS_KEY=minioadmin
34+
export AWS_EC2_METADATA_DISABLED=true
35+
36+
aws --endpoint-url http://127.0.0.1:9900/ s3 mb s3://testbucket
37+
aws --endpoint-url http://127.0.0.1:9900/ s3 cp tests/data s3://testbucket/admin/data --recursive
38+
aws --endpoint-url http://127.0.0.1:9900/ s3 cp tests/data/ontime_200.csv s3://testbucket/admin/data/ontime_200_v1.csv
39+
aws --endpoint-url http://127.0.0.1:9900/ s3 cp tests/data/ontime_200.parquet s3://testbucket/admin/data/ontime_200_v1.parquet
40+
41+
- name: Run Stateful Tests with Cluster mode (ubuntu-latest only)
42+
shell: bash
43+
run: |
44+
./scripts/ci/ci-run-stateful-tests-cluster-s3.sh
45+
46+
- name: Upload .stdout files
47+
if: failure()
48+
uses: actions/upload-artifact@v3
49+
with:
50+
name: test-stateful-cluster-linux-stdouts
51+
path: |
52+
./tests/suites/1_stateful/*/*.stdout
53+
54+
- name: Upload failure
55+
if: failure()
56+
uses: ./.github/actions/artifact_failure
57+
with:
58+
name: test-stateful-cluster-linux

.github/mergify.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ queue_rules:
1010
- check-success~=^build_(aarch64|x86_64)_musl$
1111
- check-success=test_unit
1212
- check-success=test_metactl
13-
- check-success=test_stateless_standalone_linux
14-
- check-success=test_stateless_cluster_linux
15-
- check-success=test_stateful_standalone_linux
13+
# state tests
14+
- check-success~=^test_(stateless|stateful)_(standalone|cluster)_linux$
15+
# sqllogic tests
1616
- check-success=test_sqllogic_base_standalone_linux
1717
- check-success=test_sqllogic_ydb_standalone_linux
1818
- check-success=test_sqllogic_base_cluster_linux

.github/workflows/dev-linux.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,6 @@ jobs:
112112
- uses: actions/checkout@v3
113113
- uses: ./.github/actions/test_meta_cluster
114114

115-
test_stateless_standalone_linux:
116-
timeout-minutes: 10
117-
runs-on: [self-hosted, X64, Linux, development]
118-
needs: build_gnu
119-
steps:
120-
- uses: actions/checkout@v3
121-
- uses: ./.github/actions/test_stateless_standalone_linux
122-
123-
test_stateless_cluster_linux:
124-
timeout-minutes: 15
125-
runs-on: [self-hosted, X64, Linux, development]
126-
needs: build_gnu
127-
steps:
128-
- uses: actions/checkout@v3
129-
- uses: ./.github/actions/test_stateless_cluster_linux
130-
131115
test_sqllogic_standalone_linux:
132116
timeout-minutes: 30
133117
name: test_sqllogic_${{ matrix.dirs }}_standalone_linux
@@ -161,10 +145,26 @@ jobs:
161145
with:
162146
dirs: ${{ matrix.dirs }}
163147

164-
test_stateful_standalone_linux:
165-
timeout-minutes: 10
148+
test_stateless_standalone_linux:
149+
timeout-minutes: 20
150+
runs-on: [self-hosted, X64, Linux, development]
151+
needs: build_gnu
152+
steps:
153+
- uses: actions/checkout@v3
154+
- uses: ./.github/actions/test_stateless_standalone_linux
155+
156+
test_stateless_cluster_linux:
157+
timeout-minutes: 20
166158
runs-on: [self-hosted, X64, Linux, development]
167159
needs: build_gnu
160+
steps:
161+
- uses: actions/checkout@v3
162+
- uses: ./.github/actions/test_stateless_cluster_linux
163+
164+
test_stateful_standalone_linux:
165+
timeout-minutes: 20
166+
runs-on: [ self-hosted, X64, Linux, development ]
167+
needs: build_gnu
168168
steps:
169169
- uses: actions/checkout@v3
170170
- uses: ./.github/actions/test_stateful_standalone_linux

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
# Copyright 2020-2021 The Databend Authors.
3+
# SPDX-License-Identifier: Apache-2.0.
4+
5+
echo "*************************************"
6+
echo "* Setting STORAGE_TYPE to S3. *"
7+
echo "* *"
8+
echo "* Please make sure that S3 backend *"
9+
echo "* is ready, and configured properly.*"
10+
echo "*************************************"
11+
export STORAGE_TYPE=s3
12+
export STORAGE_S3_BUCKET=testbucket
13+
export STORAGE_S3_ROOT=admin
14+
export STORAGE_S3_ENDPOINT_URL=http://127.0.0.1:9900
15+
export STORAGE_S3_ACCESS_KEY_ID=minioadmin
16+
export STORAGE_S3_SECRET_ACCESS_KEY=minioadmin
17+
export STORAGE_ALLOW_INSECURE=true
18+
19+
echo "Install dependence"
20+
python3 -m pip install --quiet mysql-connector-python
21+
22+
echo "calling test suite"
23+
echo "Starting Cluster databend-query"
24+
./scripts/ci/deploy/databend-query-cluster-3-nodes.sh
25+
26+
SCRIPT_PATH="$(cd "$(dirname "$0")" >/dev/null 2>&1 && pwd)"
27+
cd "$SCRIPT_PATH/../../tests" || exit
28+
29+
echo "Starting databend-test"
30+
./databend-test --mode 'cluster' --run-dir 1_stateful

src/common/hashtable/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ test = false
1515
common-base = { path = "../base" }
1616

1717
# Crates.io dependencies
18+
ahash = "0.7.6"
1819
ordered-float = { git = "https://github.com/andylokandy/rust-ordered-float.git", branch = "as", features = ["serde"] }
1920
primitive-types = "0.11.1"
2021

src/common/hashtable/src/hash_set.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ impl<Key: HashTableKeyable, Grower: HashTableGrower, Allocator: AllocatorTrait +
3030
self.insert_key(value.get_key(), &mut inserted);
3131
}
3232
}
33+
34+
pub fn contains(&self, key: &Key) -> bool {
35+
self.find_key(key).is_some()
36+
}
3337
}

src/common/hashtable/src/hash_table_key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl HashTableKeyable for OrderedFloat<f32> {
126126

127127
#[inline(always)]
128128
fn is_zero(&self) -> bool {
129-
self.is_nan()
129+
self.0 == 0.0
130130
}
131131

132132
#[inline(always)]
@@ -144,7 +144,7 @@ impl HashTableKeyable for OrderedFloat<f64> {
144144

145145
#[inline(always)]
146146
fn is_zero(&self) -> bool {
147-
self.is_nan()
147+
self.0 == 0.0
148148
}
149149

150150
#[inline(always)]

src/common/hashtable/src/keys_ref.rs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright 2021 Datafuse Labs.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
use std::hash::Hasher;
16+
17+
use ahash::AHasher;
18+
19+
use super::HashTableKeyable;
20+
21+
#[derive(Clone, Copy)]
22+
pub struct KeysRef {
23+
pub length: usize,
24+
pub address: usize,
25+
}
26+
27+
impl KeysRef {
28+
pub fn create(address: usize, length: usize) -> KeysRef {
29+
KeysRef { length, address }
30+
}
31+
}
32+
33+
impl Eq for KeysRef {}
34+
35+
impl PartialEq for KeysRef {
36+
fn eq(&self, other: &Self) -> bool {
37+
if self.length != other.length {
38+
return false;
39+
}
40+
41+
unsafe {
42+
let self_value = std::slice::from_raw_parts(self.address as *const u8, self.length);
43+
let other_value = std::slice::from_raw_parts(other.address as *const u8, other.length);
44+
self_value == other_value
45+
}
46+
}
47+
}
48+
49+
impl HashTableKeyable for KeysRef {
50+
const BEFORE_EQ_HASH: bool = true;
51+
52+
fn is_zero(&self) -> bool {
53+
self.length == 0
54+
}
55+
56+
fn fast_hash(&self) -> u64 {
57+
unsafe {
58+
// TODO(Winter) We need more efficient hash algorithm
59+
let value = std::slice::from_raw_parts(self.address as *const u8, self.length);
60+
61+
let mut hasher = AHasher::default();
62+
hasher.write(value);
63+
hasher.finish()
64+
}
65+
}
66+
67+
fn set_key(&mut self, new_value: &Self) {
68+
self.length = new_value.length;
69+
self.address = new_value.address;
70+
}
71+
}
72+
73+
impl std::hash::Hash for KeysRef {
74+
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
75+
let self_value =
76+
unsafe { std::slice::from_raw_parts(self.address as *const u8, self.length) };
77+
self_value.hash(state);
78+
}
79+
}

src/common/hashtable/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ mod hash_table_entity;
3636
mod hash_table_grower;
3737
mod hash_table_iter;
3838
mod hash_table_key;
39+
mod keys_ref;
3940
mod two_level_hash_table;
4041

42+
pub use keys_ref::KeysRef;
43+
4144
#[cfg(not(target_os = "linux"))]
4245
type HashTableAllocator = common_base::mem_allocator::JEAllocator;
4346
#[cfg(target_os = "linux")]

0 commit comments

Comments
 (0)