Hi All! I have a question about TTL on MapState. I...
# troubleshooting
f
Hi All! I have a question about TTL on MapState. I have created a mapState.
Copy code
StateTtlConfig ttlConfig = StateTtlConfig
        .newBuilder(Time.hours(1))
        .setUpdateType(StateTtlConfig.UpdateType.OnCreateAndWrite)
        .setStateVisibility(StateTtlConfig.StateVisibility.NeverReturnExpired)
        .cleanupFullSnapshot()
        .cleanupInRocksdbCompactFilter(1000)
        .build();
MapStateDescriptor<Long, Long> descriptor =
        new MapStateDescriptor<>("mapState", Long.class, Long.class);
descriptor.enableTimeToLive(ttlConfig);
mapState = getRuntimeContext().getMapState(descriptor);
The mapState is a mapping from timestamp to 1. Whenever there is an event arrives, I take current timestamp, and does mapState.put(currTimestamp, 1). Based on the ttl config, the mapState is supposed to have around 3600 keys, but currently the state has more than 9M keys. Clearly the ttl config didn't take effect. Is there anything I can try to fix this? I am using Flink1.13.