Skip to content

Commit f10cd0b

Browse files
authored
refactor: remove unused field step from sequence meta (#18245)
* refactor: remove unused field `start` from `SequenceMeta` This is a **Non-Breaking** change. * refactor: nexval call on a sequence should not update the last-updated timestamp Because nextval is not a DDL operation.
1 parent 147ed48 commit f10cd0b

File tree

14 files changed

+54
-18
lines changed

14 files changed

+54
-18
lines changed

src/meta/api/src/sequence_api_impl.rs

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

15-
use chrono::Utc;
1615
use databend_common_meta_app::app_error::AppError;
1716
use databend_common_meta_app::app_error::OutofSequenceRange;
1817
use databend_common_meta_app::app_error::SequenceError;
@@ -152,7 +151,6 @@ impl<KV: kvapi::KVApi<Error = MetaError> + ?Sized> SequenceApi for KV {
152151

153152
// update meta
154153
sequence_meta.current += count;
155-
sequence_meta.update_on = Utc::now();
156154

157155
let condition = vec![txn_cond_eq_seq(&ident, sequence_seq)];
158156
let if_then = vec![

src/meta/app/src/schema/sequence.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ pub struct SequenceMeta {
2828
pub create_on: DateTime<Utc>,
2929
pub update_on: DateTime<Utc>,
3030
pub comment: Option<String>,
31-
pub start: u64,
3231
pub step: i64,
3332
pub current: u64,
3433
}
@@ -39,7 +38,6 @@ impl From<CreateSequenceReq> for SequenceMeta {
3938
comment: p.comment.clone(),
4039
create_on: p.create_on,
4140
update_on: p.create_on,
42-
start: 1,
4341
step: 1,
4442
current: 1,
4543
}

src/meta/proto-conv/src/sequence_from_to_protobuf_impl.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ impl FromToProto for SequenceMeta {
3838
comment: p.comment.clone(),
3939
create_on: DateTime::<Utc>::from_pb(p.create_on)?,
4040
update_on: DateTime::<Utc>::from_pb(p.update_on)?,
41-
start: p.start,
4241
current: p.current,
4342
step: p.step,
4443
};
@@ -52,7 +51,6 @@ impl FromToProto for SequenceMeta {
5251
comment: self.comment.clone(),
5352
create_on: self.create_on.to_pb()?,
5453
update_on: self.update_on.to_pb()?,
55-
start: self.start,
5654
current: self.current,
5755
step: self.step,
5856
};

src/meta/proto-conv/src/util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ const META_CHANGE_LOG: &[(u64, &str)] = &[
161161
(129, "2025-05-30: Add: New DataType Vector"),
162162
(130, "2025-06-19: Add: New UDF imports and packages in udf definition"),
163163
(131, "2025-06-24: Add: add use_logic_type in ParquetFileFormatParam and AvroFileFormatParam"),
164+
(132, "2025-06-25: Remove: SequenceMeta.start"),
164165
// Dear developer:
165166
// If you're gonna add a new metadata version, you'll have to add a test for it.
166167
// You could just copy an existing test file(e.g., `../tests/it/v024_table_meta.rs`)

src/meta/proto-conv/tests/it/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,4 @@ mod v128_storage_network_config;
123123
mod v129_vector_datatype;
124124
mod v130_udf_imports_packages;
125125
mod v131_avro_and_parquet_file_format_params;
126+
mod v132_remove_sequence_meta_start;

src/meta/proto-conv/tests/it/proto_conv.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ fn new_sequence_meta() -> mt::SequenceMeta {
8282
create_on: DateTime::<Utc>::from_timestamp(10267, 0).unwrap(),
8383
update_on: DateTime::<Utc>::from_timestamp(10267, 0).unwrap(),
8484
comment: Some("seq".to_string()),
85-
start: 1,
8685
step: 1,
8786
current: 10,
8887
}

src/meta/proto-conv/tests/it/v088_sequence_meta.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ fn test_decode_v88_sequence_meta() -> anyhow::Result<()> {
3131
create_on: DateTime::<Utc>::from_timestamp(10267, 0).unwrap(),
3232
update_on: DateTime::<Utc>::from_timestamp(10267, 0).unwrap(),
3333
comment: Some("seq".to_string()),
34-
start: 1,
3534
step: 1,
3635
current: 10,
3736
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2023 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 chrono::DateTime;
16+
use chrono::Utc;
17+
use databend_common_meta_app::schema as mt;
18+
use fastrace::func_name;
19+
20+
use crate::common;
21+
22+
#[test]
23+
fn test_decode_v132_remove_sequence_meta_step() -> anyhow::Result<()> {
24+
let sequence_meta_v132 = vec![
25+
10, 23, 49, 57, 55, 48, 45, 48, 49, 45, 48, 49, 32, 48, 50, 58, 53, 49, 58, 48, 55, 32, 85,
26+
84, 67, 18, 23, 49, 57, 55, 48, 45, 48, 49, 45, 48, 49, 32, 48, 50, 58, 53, 49, 58, 48, 55,
27+
32, 85, 84, 67, 26, 3, 115, 101, 113, 40, 5, 48, 10, 160, 6, 132, 1, 168, 6, 24,
28+
];
29+
30+
let want = || mt::SequenceMeta {
31+
create_on: DateTime::<Utc>::from_timestamp(10267, 0).unwrap(),
32+
update_on: DateTime::<Utc>::from_timestamp(10267, 0).unwrap(),
33+
comment: Some("seq".to_string()),
34+
step: 5,
35+
current: 10,
36+
};
37+
common::test_pb_from_to(func_name!(), want())?;
38+
common::test_load_old(func_name!(), sequence_meta_v132.as_slice(), 132, want())?;
39+
40+
Ok(())
41+
}

src/meta/protos/proto/sequence.proto

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ message SequenceMeta {
2323
string create_on = 1;
2424
string update_on = 2;
2525
optional string comment = 3;
26-
uint64 start = 4;
26+
27+
// reserved: start is not used and is removed.
28+
// uint64 start = 4;
29+
reserved 4;
30+
2731
int64 step = 5;
2832
uint64 current = 6;
2933
}

src/meta/service/tests/it/api/http/features.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ async fn test_features() -> anyhow::Result<()> {
9999
let features: FeatureResponse = serde_json::from_str(&text).unwrap();
100100
assert_eq!(features.enabled, vec!["dummy".to_string()]);
101101

102+
// Wait for node-1 to catch up
103+
tokio::time::sleep(Duration::from_secs(1)).await;
104+
102105
// node-1 list features
103106
let resp = client.get(list_features_url(1)).send().await;
104107
println!("node-1 features resp: {:?}", resp);

0 commit comments

Comments
 (0)