Skip to content

Commit

Permalink
fix: ensure result correctness when enable pruning cache (#17524)
Browse files Browse the repository at this point in the history
* reproduce

* reproduce

* reproduce

* reproduce

* fix: ensure result correctness when enable pruning cache
  • Loading branch information
dqhl76 authored Feb 27, 2025
1 parent aeaf443 commit 7b27c3a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 3 deletions.
2 changes: 2 additions & 0 deletions scripts/ci/ci-run-stateful-tests-cluster-minio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export STORAGE_ALLOW_INSECURE=true

echo "Install dependence"
python3 -m pip install --quiet mysql-connector-python requests
sudo apt-get update -yq
sudo apt-get install -yq lsof

echo "calling test suite"
echo "Starting Cluster databend-query"
Expand Down
2 changes: 2 additions & 0 deletions scripts/ci/ci-run-stateful-tests-standalone-minio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export STORAGE_ALLOW_INSECURE=true

echo "Install dependence"
python3 -m pip install --quiet mysql-connector-python requests
sudo apt-get update -yq
sudo apt-get install -yq lsof

echo "calling test suite"
echo "Starting standalone DatabendQuery(debug)"
Expand Down
6 changes: 3 additions & 3 deletions src/query/storages/fuse/src/operations/read_partitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl FuseTable {
plan: &DataSourcePlan,
source_pipeline: &mut Pipeline,
) -> Result<Option<Pipeline>> {
let segments_location = plan.statistics.snapshot.clone();
let snapshot = plan.statistics.snapshot.clone();
let table_schema = self.schema_with_stream();
let dal = self.operator.clone();
let mut lazy_init_segments = Vec::with_capacity(plan.parts.len());
Expand All @@ -180,7 +180,7 @@ impl FuseTable {
lazy_init_segments.push(SegmentLocation {
segment_idx: lazy_part_info.segment_index,
location: lazy_part_info.segment_location.clone(),
snapshot_loc: segments_location.clone(),
snapshot_loc: snapshot.clone(),
});
}
}
Expand All @@ -202,7 +202,7 @@ impl FuseTable {
.map(|push_downs| {
format!(
"{:x}",
Sha256::digest(format!("{:?}_{:?}", segments_location, push_downs))
Sha256::digest(format!("{:?}_{:?}", lazy_init_segments, push_downs))
)
});

Expand Down
14 changes: 14 additions & 0 deletions tests/suites/1_stateful/02_query/02_0010_issue_17523.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
1
1
1
1
test_text1
test_text2
test_text3
test_text4
2
test_text1
test_text2
test_text3
test_text4
3
44 changes: 44 additions & 0 deletions tests/suites/1_stateful/02_query/02_0010_issue_17523.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../../../shell_env.sh

# Skip in standalone mode
port_check=$(sudo lsof -i :9093)
if [ -z "$port_check" ]; then
echo -e "1\n1\n1\n1\ntest_text1\ntest_text2\ntest_text3\ntest_text4\n2\ntest_text1\ntest_text2\ntest_text3\ntest_text4\n3"
exit 0
fi

echo "drop table if exists table_test_02_0010;" | $BENDSQL_CLIENT_CONNECT

echo "create table table_test_02_0010(TEXT String);" | $BENDSQL_CLIENT_CONNECT


table_inserts=(
"INSERT INTO table_test_02_0010 VALUES('test_text1');"
"INSERT INTO table_test_02_0010 VALUES('test_text2');"
"INSERT INTO table_test_02_0010 VALUES('test_text3');"
"INSERT INTO table_test_02_0010 VALUES('test_text4');"
)

for i in "${table_inserts[@]}"; do
echo "$i" | $BENDSQL_CLIENT_CONNECT
done


echo "select * from table_test_02_0010 order by text;" | $BENDSQL_CLIENT_CONNECT

# kill a node
sudo lsof -i :9093 -t | xargs -r sudo kill -9

echo "select count(*) from system.clusters;" | $BENDSQL_CLIENT_CONNECT

echo "select * from table_test_02_0010 order by text;" | $BENDSQL_CLIENT_CONNECT

# restart the node
ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../../../../ && pwd)"
env "RUST_BACKTRACE=1" nohup "$ROOTDIR"/target/${BUILD_PROFILE}/databend-query -c "$ROOTDIR"/scripts/ci/deploy/config/databend-query-node-3.toml --internal-enable-sandbox-tenant > "$ROOTDIR"/.databend/query-3.out 2>&1 &
python3 "$ROOTDIR"/scripts/ci/wait_tcp.py --timeout 30 --port 9093 > /dev/null 2>&1

echo "select count(*) from system.clusters;" | $BENDSQL_CLIENT_CONNECT

0 comments on commit 7b27c3a

Please sign in to comment.