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 @@ -103,7 +103,6 @@ void beforeEach() {
execEnv = StreamExecutionEnvironment.getExecutionEnvironment();
execEnv.setRuntimeMode(RuntimeExecutionMode.STREAMING);
execEnv.setParallelism(2);
execEnv.enableCheckpointing(500);
}

protected long createTable(TablePath tablePath, Schema schema) throws Exception {
Expand Down
73 changes: 72 additions & 1 deletion fluss-flink/fluss-flink-tiering/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,77 @@
<version>${flink.minor.version}</version>
<scope>provided</scope>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>org.apache.fluss</groupId>
<artifactId>fluss-flink-common</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>

<dependency>
<groupId>org.apache.fluss</groupId>
<artifactId>fluss-server</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.fluss</groupId>
<artifactId>fluss-server</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>

<dependency>
<groupId>org.apache.fluss</groupId>
<artifactId>fluss-common</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>

<dependency>
<groupId>org.apache.fluss</groupId>
<artifactId>fluss-test-utils</artifactId>
</dependency>

<!-- for curator TestingServer -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>
<version>${curator.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients</artifactId>
<version>${flink.minor.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-base</artifactId>
<version>${flink.minor.version}</version>
<scope>test</scope>
</dependency>

<!--
Required at test runtime because TieringSource loads FlinkConnectorOptionsUtils, which
references ValidationException from flink-table-common. fluss-flink-common declares this
dependency as provided, so it is not transitively available to this module's tests.
-->
<dependency>
Comment thread
Shawn-Hx marked this conversation as resolved.
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-common</artifactId>
<version>${flink.minor.version}</version>
<scope>test</scope>
</dependency>
</dependencies>


Expand Down Expand Up @@ -85,4 +156,4 @@

</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
import org.apache.fluss.flink.adapter.MultipleParameterToolAdapter;

import org.apache.flink.configuration.JobManagerOptions;
import org.apache.flink.configuration.RestartStrategyOptions;
import org.apache.flink.core.execution.JobClient;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Map;
import java.util.ServiceLoader;

import static org.apache.flink.configuration.RestartStrategyOptions.RestartStrategyType.EXPONENTIAL_DELAY;
import static org.apache.flink.runtime.executiongraph.failover.FailoverStrategyFactoryLoader.FULL_RESTART_STRATEGY_NAME;
import static org.apache.fluss.flink.tiering.source.TieringSourceOptions.DATA_LAKE_CONFIG_PREFIX;
import static org.apache.fluss.utils.PropertiesUtils.extractAndRemovePrefix;
Expand Down Expand Up @@ -96,6 +98,11 @@ public FlussLakeTiering(String[] args) {
org.apache.flink.configuration.Configuration flinkConfig =
new org.apache.flink.configuration.Configuration();
flinkConfig.set(JobManagerOptions.EXECUTION_FAILOVER_STRATEGY, FULL_RESTART_STRATEGY_NAME);
// Configure restart strategy: the tiering job is completely stateless (offsets are
// persisted in Fluss Server's LakeSnapshot, not in Flink checkpoint state), so it is
// safe to restart indefinitely on failure. Without this, Flink defaults to "no-restart"
// when checkpoint is not enabled, causing the job to fail permanently on any exception.
flinkConfig.set(RestartStrategyOptions.RESTART_STRATEGY, EXPONENTIAL_DELAY.getMainValue());

execEnv = StreamExecutionEnvironment.getExecutionEnvironment(flinkConfig);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@

package org.apache.fluss.flink.tiering;

import org.apache.fluss.config.ConfigOptions;
import org.apache.fluss.lake.values.TestingValuesLake;
import org.apache.fluss.metadata.DataLakeFormat;
import org.apache.fluss.metadata.Schema;
import org.apache.fluss.metadata.TableBucket;
import org.apache.fluss.metadata.TablePath;
import org.apache.fluss.row.InternalRow;
import org.apache.fluss.types.DataTypes;

import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.core.execution.JobClient;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
Expand Down Expand Up @@ -59,6 +63,24 @@ protected static void afterAll() throws Exception {
FlinkTieringTestBase.afterAll();
}

@BeforeEach
@Override
void beforeEach() {
String bootstrapServers = String.join(",", clientConf.get(ConfigOptions.BOOTSTRAP_SERVERS));
String[] args = {
"--fluss.bootstrap.servers",
bootstrapServers,
"--datalake.format",
DataLakeFormat.PAIMON.toString()
};
FlussLakeTiering tiering = new FlussLakeTiering(args);
execEnv = tiering.execEnv;
execEnv.setRuntimeMode(RuntimeExecutionMode.STREAMING);
execEnv.setParallelism(2);

assertThat(execEnv.getCheckpointConfig().isCheckpointingEnabled()).isFalse();
}

@Test
void testTiering() throws Exception {
// create a pk table, write some records and wait until snapshot finished
Expand All @@ -71,8 +93,8 @@ void testTiering() throws Exception {
writeRows(t1, rows, false);
FLUSS_CLUSTER_EXTENSION.triggerAndWaitSnapshot(t1);

// fail the first write to the pk table
TestingValuesLake.failWhen(t1.toString()).failWriteOnce();
// fail the first two writes to the pk table
TestingValuesLake.failWhen(t1.toString()).failWriteNext(2);

// then start tiering job
JobClient jobClient = buildTieringJob(execEnv);
Expand All @@ -96,7 +118,9 @@ void testTiering() throws Exception {

checkDataInValuesTable(t1, expectedRows);
} finally {
jobClient.cancel().get();
if (!jobClient.getJobExecutionResult().isDone()) {
jobClient.cancel().get();
}
}
}

Expand Down
Loading