Andre Luiz
12/16/2024, 6:06 PMtable, we have multiple instances prefixed by their shard name, such as: s0-table, s1-table, sN-table. Each table connects to its respective shard infrastructure application, called app, which reads from and writes to them.
Here is some context about these tables and the project:
• They belong to a large application, with each table from a shard containing about 20TB of data.
• They experience a significant amount of write activity, with around 20,000 events per minute on the DynamoDB Stream for each shard's table.
• They are all in On-Demand mode.
• We have a way of comparing data to validade data loses.
Given this scenario, we've developed a single Flink application that consumes the DynamoDB Stream from each table from each shard for the same app and outputs the data into a Kafka topic for downstream use. However, we've been noticing unusual behavior, including data loss across all streams. There are no relevant logs indicating data loss. We also observed that this data loss occurs even when we are current with the stream time, as indicated by the millisBehindSource metric being less than a second.
We attempted a deeper investigation, and the only progress we made was when we ran a new Flink application consuming from only one stream from a single table/shard. In this case, there was no data loss. Beyond that, we haven't identified the root cause of the data loss when consuming multiple DynamoDB Streams in a single Flink application, even without backpressure or lag.
Is there any configuration we're missing related to the connector/AWS SDK? Does the DynamoDB Stream Source support consuming from multiple tables? Is there a reason a single DynamoDB Stream consumer in a Flink application would prevent data loss?
I'll post a snippet of how this application works in the thread.
Thank you in advance for any help.
André DinizAndre Luiz
12/16/2024, 6:06 PMpublic class Main {
public static void main(String[] args) throws Exception {
...
var streamingEnvironment = StreamExecutionEnvironment.getExecutionEnvironment();
config.shards.forEach(s -> GatewayTopology.forShard(streamingEnvironment, config, s));
streamingEnvironment.execute("flink-dynamodb-reader");
}
}Andre Luiz
12/16/2024, 6:06 PMpublic class GatewayTopology {
public static void forShard(StreamExecutionEnvironment env, AppConfig config, AppConfig.Shard shard) {
var source = DDBStreamsSource.of(config.aws, shard); // This Creates a DynamoDBStreamSource that Receives a Record and serializers it to a string.
var sink = RecordKafkaSink.of(config.kafka, shard);// This creates a KafkaSink for that data.
defineWorkflow(env, shard, source, sink);
}
static void defineWorkflow(
StreamExecutionEnvironment env,
AppConfig.Shard shard,
DynamoDbStreamsSource<String> source,
KafkaSink<String> sink) {
final var shardName = shard.name;
env.fromSource(
source,
WatermarkStrategy.<String>forMonotonousTimestamps()
.withIdleness(shard.sourceIdleness.toJavaDuration()),
String.format("dynamodb-stream-source-shard-%s", shardName),
TypeInformation.of(String.class))
.uid(String.format("dynamodb-stream-source-shard-%s", shardName))
.sinkTo(sink)
.uid(String.format("kafka-sink-shard-%s", shardName));
}
}Andre Luiz
12/17/2024, 12:13 PMAbhi Gupta
12/18/2024, 10:31 AM