Skip to content

Commit dd466ad

Browse files
committed
Merge branch 'main' of https://github.com/datafuselabs/databend into fixxxxx
2 parents 2983891 + 0c878d2 commit dd466ad

File tree

19 files changed

+4925
-925
lines changed

19 files changed

+4925
-925
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: Idempotent Copy
3+
description: Avoid duplicating when copy stage files into a table
4+
---
5+
6+
- Tracking Issue: https://github.com/datafuselabs/databend/issues/6338
7+
8+
## Summary
9+
10+
When streaming copy stage files into a table, there is a chance that some files have already been copied, So it needs some ways to avoid duplicate copying files, make it an `idempotent` operation.
11+
12+
## Save copy into table stage files meta information in meta service
13+
14+
Whenever copy stage files into a table, save the stage file meta information into the meta service:
15+
16+
- key: combined with `(tenant, database, table, file name)`.
17+
- value: value MUST includes all the meta of a stage file, such as `content-length`,`etag`,`last modified`.
18+
19+
20+
21+
![](/img/rfc/20220909-idempotent-copy/stage-file-meta.png)
22+
23+
24+
25+
The expiration time of the stage file meta information is 64 days by default.
26+
27+
## Avoiding duplicates when copy stage files into a table
28+
29+
Using the stage file meta information, whenever copy stage files into a table, follow these steps:
30+
31+
* First, get all the table file meta information of the copy stage files that want to copy into the table(if any).
32+
* Second, get all the stage file meta information.
33+
* Third, compare the table file meta information with stage file meta information:
34+
* If they matched, this file is just ignored without copying.
35+
* Else, copy the stage file and up-insert into the table stage file meta.
36+
37+
38+
39+
![](/img/rfc/20220909-idempotent-copy/example.png)
40+
41+
42+
43+
Take the image above as an example:
44+
45+
* Client make a request to copy thress files (file1, file2, file3) into table.
46+
47+
* Get the table stage file meta of (file1, file2, file3).
48+
49+
* In the meta service, only found (file1,file3) stage file information.
50+
51+
* Compare the table stage file information with stage file information, and found that file1 has not been changed, so file1 will be ignored in this copy operation, and (file2,file3) will be copied.
52+
53+
* After copying new files, (file2, file3) stage file information will be saved into table file information.
54+
55+
56+
Loading
Loading

src/meta/client/src/grpc_action.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,9 @@ pub enum MetaGrpcWriteReq {
5656
pub enum MetaGrpcReadReq {
5757
GetKV(GetKVReq),
5858
MGetKV(MGetKVReq),
59-
// #[deprecated(since = "0.7.57-nightly", note = "deprecated since 2022-05-23")]
60-
PrefixListKV(PrefixListReq),
6159
ListKV(ListKVReq), // since 2022-05-23
6260
}
6361

64-
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
65-
pub struct PrefixListReq(pub String);
66-
6762
/// Try convert tonic::Request<RaftRequest> to DoActionAction.
6863
impl TryInto<MetaGrpcWriteReq> for Request<RaftRequest> {
6964
type Error = tonic::Status;

src/meta/service/src/executor/action_handler.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ impl ActionHandler {
7474
incr_meta_metrics_meta_request_result(r.is_ok());
7575
RaftReply::from(r)
7676
}
77-
MetaGrpcReadReq::PrefixListKV(a) => {
78-
let r = self.meta_node.prefix_list_kv(&a.0).await;
79-
incr_meta_metrics_meta_request_result(r.is_ok());
80-
RaftReply::from(r)
81-
}
8277
}
8378
}
8479

src/meta/service/src/version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub static METASRV_SEMVER: Lazy<Version> = Lazy::new(|| {
4747
pub static MIN_METACLI_SEMVER: Version = Version {
4848
major: 0,
4949
minor: 7,
50-
patch: 57,
50+
patch: 59,
5151
pre: Prerelease::EMPTY,
5252
build: BuildMetadata::EMPTY,
5353
};

src/query/codegen/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ common-expression = { path = "../expression" }
2121
# TODO(andylokandy): Use the version from crates.io once
2222
# https://github.com/reem/rust-ordered-float/pull/110 is released.
2323
ordered-float = { git = "https://github.com/andylokandy/rust-ordered-float.git", branch = "as", features = ["serde"] }
24+
itertools = "0.10"
2425
serde = { version = "1.0.137", features = ["derive"] }
2526
serde_json = "1.0.81"

src/query/codegen/src/bin/codegen.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use codegen::writes::codegen_arithmetic_type;
16-
use codegen::writes::codegen_arithmetic_type_v2;
17-
1815
fn main() {
19-
codegen_arithmetic_type();
20-
codegen_arithmetic_type_v2();
16+
codegen::writes::codegen_arithmetic_type();
17+
codegen::writes::codegen_arithmetic_type_v2();
18+
codegen::writes::codegen_register();
2119
}

src/query/codegen/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#![feature(exit_status_error)]
16+
1517
pub mod writes;

0 commit comments

Comments
 (0)