Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,22 @@ public class ConfigOptions {
+ PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS.key()
+ "\".");

public static final ConfigOption<Integer> COORDINATOR_BULKLOAD_MAX_TARGETS =
key("coordinator.bulkload.max-targets")
.intType()
.defaultValue(1000)
.withDescription(
"Maximum number of targets in one bulk load transaction. A bulk load target is"
+ " an entire non-partitioned table or one selected partition of a partitioned table,"
+ " regardless of how many buckets it contains.");

public static final ConfigOption<Duration> COORDINATOR_BULKLOAD_RESULT_RETENTION =
key("coordinator.bulkload.result-retention")
.durationType()
.defaultValue(Duration.ofDays(7))
.withDescription(
"Minimum retention of terminal BulkLoad results while the table exists.");

public static final ConfigOption<Duration> AUTO_PARTITION_CHECK_INTERVAL =
key("auto-partition.check.interval")
.durationType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public static void validateCoordinatorConfigs(Configuration conf) {
validateServerConfigs(conf);
validMinDuration(conf, ConfigOptions.COORDINATOR_CONTROL_REQUEST_RETRY_BACKOFF, 1);
validMinDuration(conf, ConfigOptions.COORDINATOR_CONTROL_REQUEST_TIMEOUT, 1);
validMinValue(conf, ConfigOptions.COORDINATOR_BULKLOAD_MAX_TARGETS, 1);
validMinDuration(conf, ConfigOptions.COORDINATOR_BULKLOAD_RESULT_RETENTION, 1);
}

public static void validateTabletConfigs(Configuration conf) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.fluss.exception;

import org.apache.fluss.annotation.PublicEvolving;

/** BulkLoad transaction has incomplete buckets. */
@PublicEvolving
public class BulkLoadIncompleteException extends ApiException {
private static final long serialVersionUID = 1L;

public BulkLoadIncompleteException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.fluss.rpc.gateway;

import org.apache.fluss.rpc.messages.AbortBulkLoadRequest;
import org.apache.fluss.rpc.messages.AbortBulkLoadResponse;
import org.apache.fluss.rpc.messages.AcquireKvSnapshotLeaseRequest;
import org.apache.fluss.rpc.messages.AcquireKvSnapshotLeaseResponse;
import org.apache.fluss.rpc.messages.AddServerTagByRackRequest;
Expand All @@ -31,10 +33,14 @@
import org.apache.fluss.rpc.messages.AlterDatabaseResponse;
import org.apache.fluss.rpc.messages.AlterTableRequest;
import org.apache.fluss.rpc.messages.AlterTableResponse;
import org.apache.fluss.rpc.messages.BeginBulkLoadRequest;
import org.apache.fluss.rpc.messages.BeginBulkLoadResponse;
import org.apache.fluss.rpc.messages.CancelRebalanceRequest;
import org.apache.fluss.rpc.messages.CancelRebalanceResponse;
import org.apache.fluss.rpc.messages.CommitBulkLoadBucketSnapshotRequest;
import org.apache.fluss.rpc.messages.CommitBulkLoadBucketSnapshotResponse;
import org.apache.fluss.rpc.messages.CommitBulkLoadRequest;
import org.apache.fluss.rpc.messages.CommitBulkLoadResponse;
import org.apache.fluss.rpc.messages.CreateAclsRequest;
import org.apache.fluss.rpc.messages.CreateAclsResponse;
import org.apache.fluss.rpc.messages.CreateDatabaseRequest;
Expand All @@ -59,8 +65,12 @@
import org.apache.fluss.rpc.messages.DropPartitionResponse;
import org.apache.fluss.rpc.messages.DropTableRequest;
import org.apache.fluss.rpc.messages.DropTableResponse;
import org.apache.fluss.rpc.messages.GetBulkLoadInfoRequest;
import org.apache.fluss.rpc.messages.GetBulkLoadInfoResponse;
import org.apache.fluss.rpc.messages.GetProducerOffsetsRequest;
import org.apache.fluss.rpc.messages.GetProducerOffsetsResponse;
import org.apache.fluss.rpc.messages.ListInProgressBulkLoadsRequest;
import org.apache.fluss.rpc.messages.ListInProgressBulkLoadsResponse;
import org.apache.fluss.rpc.messages.ListKvSnapshotsRequest;
import org.apache.fluss.rpc.messages.ListKvSnapshotsResponse;
import org.apache.fluss.rpc.messages.ListRebalanceProgressRequest;
Expand Down Expand Up @@ -287,4 +297,25 @@ CompletableFuture<ListRemoteLogManifestsResponse> listRemoteLogManifests(
*/
@RPC(api = ApiKeys.LIST_KV_SNAPSHOTS)
CompletableFuture<ListKvSnapshotsResponse> listKvSnapshots(ListKvSnapshotsRequest request);

/** Starts a bulk load or returns the retained transaction for the same ID. */
@RPC(api = ApiKeys.BEGIN_BULK_LOAD)
CompletableFuture<BeginBulkLoadResponse> beginBulkLoad(BeginBulkLoadRequest request);

/** Completes a bulk load once its effective targets have committed. */
@RPC(api = ApiKeys.COMMIT_BULK_LOAD)
CompletableFuture<CommitBulkLoadResponse> commitBulkLoad(CommitBulkLoadRequest request);

/** Ends a bulk load while preserving its committed buckets. */
@RPC(api = ApiKeys.ABORT_BULK_LOAD)
CompletableFuture<AbortBulkLoadResponse> abortBulkLoad(AbortBulkLoadRequest request);

/** Returns retained progress for a BulkLoad transaction. */
@RPC(api = ApiKeys.GET_BULK_LOAD_INFO)
CompletableFuture<GetBulkLoadInfoResponse> getBulkLoadInfo(GetBulkLoadInfoRequest request);

/** Lists RUNNING transactions matching the selected physical targets. */
@RPC(api = ApiKeys.LIST_IN_PROGRESS_BULK_LOADS)
CompletableFuture<ListInProgressBulkLoadsResponse> listInProgressBulkLoads(
ListInProgressBulkLoadsRequest request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ public enum ApiKeys {
CREATE_TABLE_FROM_LAKE(1074, 0, 0, PUBLIC),
DESCRIBE_CLUSTER(1075, 0, 0, PUBLIC),
ALLOCATE_BULK_LOAD_BUCKET_SNAPSHOT(1076, 0, 0, PUBLIC),
COMMIT_BULK_LOAD_BUCKET_SNAPSHOT(1077, 0, 0, PUBLIC);
COMMIT_BULK_LOAD_BUCKET_SNAPSHOT(1077, 0, 0, PUBLIC),
BEGIN_BULK_LOAD(1078, 0, 0, PUBLIC),
COMMIT_BULK_LOAD(1079, 0, 0, PUBLIC),
ABORT_BULK_LOAD(1080, 0, 0, PUBLIC),
GET_BULK_LOAD_INFO(1081, 0, 0, PUBLIC),
LIST_IN_PROGRESS_BULK_LOADS(1082, 0, 0, PUBLIC);

private static final Map<Integer, ApiKeys> ID_TO_TYPE =
Arrays.stream(ApiKeys.values())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.fluss.exception.AuthenticationException;
import org.apache.fluss.exception.AuthorizationException;
import org.apache.fluss.exception.BulkLoadConflictException;
import org.apache.fluss.exception.BulkLoadIncompleteException;
import org.apache.fluss.exception.BulkLoadNotFoundException;
import org.apache.fluss.exception.BulkLoadStateException;
import org.apache.fluss.exception.BulkLoadTargetWithdrawnException;
Expand Down Expand Up @@ -340,7 +341,9 @@ public enum Errors {
INVALID_BULK_LOAD_SNAPSHOT(
85, "BulkLoad snapshot input is invalid.", InvalidBulkLoadSnapshotException::new),
BULK_LOAD_TARGET_WITHDRAWN(
86, "BulkLoad target has been withdrawn.", BulkLoadTargetWithdrawnException::new);
86, "BulkLoad target has been withdrawn.", BulkLoadTargetWithdrawnException::new),
BULK_LOAD_INCOMPLETE(
87, "BulkLoad transaction is incomplete.", BulkLoadIncompleteException::new);

private static final Logger LOG = LoggerFactory.getLogger(Errors.class);

Expand Down
66 changes: 66 additions & 0 deletions fluss-rpc/src/main/proto/FlussApi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,32 @@ message PbBulkLoadHandle {
required string bulk_load_id = 2;
}

message PbBulkLoadStatus {
required PbBulkLoadHandle handle = 1;
// 0 = RUNNING, 1 = COMMITTED, 2 = ABORTED.
required int32 state = 2;
Comment thread
platinumhamburg marked this conversation as resolved.
Resolved
required int64 created_time = 3;
optional int64 finished_time = 4;
optional string abort_message = 5;
}

message PbBulkLoadTargetInfo {
optional int64 partition_id = 1;
optional string partition_name = 2;
required int32 bucket_count = 3;
required string remote_data_dir = 4;
}
message BeginBulkLoadRequest {
required PbTablePath table_path = 1;
repeated string partition_names = 2;
optional string bulk_load_id = 3;
}

message BeginBulkLoadResponse {
required PbBulkLoadStatus status = 1;
required PbTableInfo table_info = 2;
repeated PbBulkLoadTargetInfo targets = 3;
}
message AllocateBulkLoadBucketSnapshotRequest {
required PbBulkLoadHandle handle = 1;
optional int64 partition_id = 2;
Expand All @@ -1000,6 +1026,46 @@ message CommitBulkLoadBucketSnapshotRequest {
}

message CommitBulkLoadBucketSnapshotResponse {}
message CommitBulkLoadRequest {
required PbBulkLoadHandle handle = 1;
}

message CommitBulkLoadResponse {
required PbBulkLoadStatus status = 1;
}
message AbortBulkLoadRequest {
required PbBulkLoadHandle handle = 1;
optional string abort_message = 2;
}

message AbortBulkLoadResponse {
required PbBulkLoadStatus status = 1;
}
message GetBulkLoadInfoRequest {
required PbBulkLoadHandle handle = 1;
}

message PbBulkLoadTargetProgress {
optional int64 partition_id = 1;
required int32 bucket_count = 2;
required int64 allocated_bucket_count = 3;
required int64 committed_bucket_count = 4;
required bool withdrawn = 5;
}

message GetBulkLoadInfoResponse {
required PbBulkLoadStatus status = 1;
repeated PbBulkLoadTargetProgress targets = 2;
}
message ListInProgressBulkLoadsRequest {
required PbTablePath table_path = 1;
repeated string partition_names = 2;
}

message ListInProgressBulkLoadsResponse {
repeated PbBulkLoadStatus transactions = 1;
}

// --------------- Inner classes ----------------
message PbTabletServerLoad {
required int32 server_id = 1;
Expand Down
102 changes: 102 additions & 0 deletions fluss-rust/crates/fluss/src/proto/fluss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,49 @@ pub struct PbBulkLoadHandle {
pub bulk_load_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PbBulkLoadStatus {
#[prost(message, required, tag = "1")]
pub handle: PbBulkLoadHandle,
/// 0 = RUNNING, 1 = COMMITTED, 2 = ABORTED.
#[prost(int32, required, tag = "2")]
pub state: i32,
#[prost(int64, required, tag = "3")]
pub created_time: i64,
#[prost(int64, optional, tag = "4")]
pub finished_time: ::core::option::Option<i64>,
#[prost(string, optional, tag = "5")]
pub abort_message: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PbBulkLoadTargetInfo {
#[prost(int64, optional, tag = "1")]
pub partition_id: ::core::option::Option<i64>,
#[prost(string, optional, tag = "2")]
pub partition_name: ::core::option::Option<::prost::alloc::string::String>,
#[prost(int32, required, tag = "3")]
pub bucket_count: i32,
#[prost(string, required, tag = "4")]
pub remote_data_dir: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct BeginBulkLoadRequest {
#[prost(message, required, tag = "1")]
pub table_path: PbTablePath,
#[prost(string, repeated, tag = "2")]
pub partition_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, optional, tag = "3")]
pub bulk_load_id: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BeginBulkLoadResponse {
#[prost(message, required, tag = "1")]
pub status: PbBulkLoadStatus,
#[prost(message, required, tag = "2")]
pub table_info: PbTableInfo,
#[prost(message, repeated, tag = "3")]
pub targets: ::prost::alloc::vec::Vec<PbBulkLoadTargetInfo>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct AllocateBulkLoadBucketSnapshotRequest {
#[prost(message, required, tag = "1")]
pub handle: PbBulkLoadHandle,
Expand Down Expand Up @@ -1306,6 +1349,65 @@ pub struct CommitBulkLoadBucketSnapshotRequest {
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CommitBulkLoadBucketSnapshotResponse {}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CommitBulkLoadRequest {
#[prost(message, required, tag = "1")]
pub handle: PbBulkLoadHandle,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CommitBulkLoadResponse {
#[prost(message, required, tag = "1")]
pub status: PbBulkLoadStatus,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct AbortBulkLoadRequest {
#[prost(message, required, tag = "1")]
pub handle: PbBulkLoadHandle,
#[prost(string, optional, tag = "2")]
pub abort_message: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct AbortBulkLoadResponse {
#[prost(message, required, tag = "1")]
pub status: PbBulkLoadStatus,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetBulkLoadInfoRequest {
#[prost(message, required, tag = "1")]
pub handle: PbBulkLoadHandle,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PbBulkLoadTargetProgress {
#[prost(int64, optional, tag = "1")]
pub partition_id: ::core::option::Option<i64>,
#[prost(int32, required, tag = "2")]
pub bucket_count: i32,
#[prost(int64, required, tag = "3")]
pub allocated_bucket_count: i64,
#[prost(int64, required, tag = "4")]
pub committed_bucket_count: i64,
#[prost(bool, required, tag = "5")]
pub withdrawn: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetBulkLoadInfoResponse {
#[prost(message, required, tag = "1")]
pub status: PbBulkLoadStatus,
#[prost(message, repeated, tag = "2")]
pub targets: ::prost::alloc::vec::Vec<PbBulkLoadTargetProgress>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ListInProgressBulkLoadsRequest {
#[prost(message, required, tag = "1")]
pub table_path: PbTablePath,
#[prost(string, repeated, tag = "2")]
pub partition_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListInProgressBulkLoadsResponse {
#[prost(message, repeated, tag = "1")]
pub transactions: ::prost::alloc::vec::Vec<PbBulkLoadStatus>,
}
/// --------------- Inner classes ----------------
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PbTabletServerLoad {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,12 @@ public boolean isBulkLoadPublicationPending(TableBucket bucket) {
return unverifiedBulkLoadBuckets.contains(bucket);
}

/** Returns whether publication verification still needs bucket records for this table. */
public boolean hasPendingBulkLoadPublication(long tableId) {
return unverifiedBulkLoadBuckets.stream()
.anyMatch(bucket -> bucket.getTableId() == tableId);
}

void setBulkLoadPublicationPending(TableBucket bucket, boolean pending) {
if (pending) {
unverifiedBulkLoadBuckets.add(bucket);
Expand Down Expand Up @@ -832,7 +838,7 @@ public void removeTable(long tableId) {

TablePath tablePath = tablePathById.remove(tableId);
if (tablePath != null) {
tableIdByPath.remove(tablePath);
tableIdByPath.remove(tablePath, tableId);
}
tableInfoById.remove(tableId);
}
Expand Down Expand Up @@ -861,7 +867,7 @@ public void removePartition(TablePartition tablePartition) {
PhysicalTablePath physicalTablePath =
pathByPartitionId.remove(tablePartition.getPartitionId());
if (physicalTablePath != null) {
partitionIdByPath.remove(physicalTablePath);
partitionIdByPath.remove(physicalTablePath, tablePartition.getPartitionId());
}

partitionInfoById.remove(tablePartition.getPartitionId());
Expand Down
Loading
Loading