如果看不到密钥但 rocksdb 有关于该密钥的状态,会发生什么?
What would happen if a key is not seen but rocksdb has state about that key?
假设我有这样一个过程函数(带有 rocksdb 状态后端):
public class Test extends KeyedProcessFunction<...>
{
private transient ValueState<Integer> ...;
...
@Override
public void open(Configuration parameters) throws Exception
{
StateTtlConfig ttlConfig = StateTtlConfig
.newBuilder(Time.minutes(10))
.setUpdateType(StateTtlConfig.UpdateType.OnCreateAndWrite)
.setStateVisibility(StateTtlConfig.StateVisibility.NeverReturnExpired)
.cleanupInRocksdbCompactFilter(1000)
.build();
ValueStateDescriptor<Integer> testDescr = new ValueStateDescriptor<Integer>(
"test",
TypeInformation.of(Integer.class)
);
testDescr.enableTimeToLive(ttlConfig);
...
}
}
kafkaSource.keyby(object -> object.getKey()).process(new Test()))...;
假设这是一个无界流应用
假设我已经看到名为“orange”的键,但只见过一次(或者只是假设为键“orange”调用了一次处理函数),并假设不会有名为“orange”的键。在那种情况下,密钥“orange”将永远留在 rocksdb 中?
在创建该键状态 10 分钟后发生的第一次 RocksDB 压缩期间,将从 RocksDB 中删除非活动键“orange”的状态(因为 TTL 配置构建器配置了 10分钟 TTL 超时)。在那之前,状态将在 RocksDB 中徘徊,但是因为你已经配置 StateVisibility.NeverReturnExpired
如果你尝试访问它,Flink 会假装它不存在。
假设我有这样一个过程函数(带有 rocksdb 状态后端):
public class Test extends KeyedProcessFunction<...>
{
private transient ValueState<Integer> ...;
...
@Override
public void open(Configuration parameters) throws Exception
{
StateTtlConfig ttlConfig = StateTtlConfig
.newBuilder(Time.minutes(10))
.setUpdateType(StateTtlConfig.UpdateType.OnCreateAndWrite)
.setStateVisibility(StateTtlConfig.StateVisibility.NeverReturnExpired)
.cleanupInRocksdbCompactFilter(1000)
.build();
ValueStateDescriptor<Integer> testDescr = new ValueStateDescriptor<Integer>(
"test",
TypeInformation.of(Integer.class)
);
testDescr.enableTimeToLive(ttlConfig);
...
}
}
kafkaSource.keyby(object -> object.getKey()).process(new Test()))...;
假设这是一个无界流应用 假设我已经看到名为“orange”的键,但只见过一次(或者只是假设为键“orange”调用了一次处理函数),并假设不会有名为“orange”的键。在那种情况下,密钥“orange”将永远留在 rocksdb 中?
在创建该键状态 10 分钟后发生的第一次 RocksDB 压缩期间,将从 RocksDB 中删除非活动键“orange”的状态(因为 TTL 配置构建器配置了 10分钟 TTL 超时)。在那之前,状态将在 RocksDB 中徘徊,但是因为你已经配置 StateVisibility.NeverReturnExpired
如果你尝试访问它,Flink 会假装它不存在。