Mark Lidenberg
02/23/2024, 2:24 PMtaskmanager.memory.task.off-heap.size: 256mb
taskmanager.memory.managed.size: 128mb
state.backend.type: hashmap
state.backend.incremental: "true"
state.checkpoints.dir: null
state.savepoints.dir: null
TTL is 1 second with incremental cleanup I don't use checkpoints and savepoints to keep it simple.
State config:
def open(self, runtime_context: RuntimeContext):
state_descriptor = ValueStateDescriptor(
name="my_state",
value_type_info=Types.STRING(),
)
state_descriptor.enable_time_to_live(
ttl_config=StateTtlConfig.new_builder(Time.seconds(1))
.cleanup_incrementally(cleanup_size=10, run_cleanup_for_every_record=True)
.set_update_type(StateTtlConfig.UpdateType.OnCreateAndWrite)
.set_state_visibility(StateTtlConfig.StateVisibility.NeverReturnExpired)
.build()
)
self.state = runtime_context.get_state(state_descriptor)
Sample piece of output, formatted
LOG_TIMESTAMP: 2024-02-23 13:19:55,729
STATE VALUE TYPE: class 'str' (expected to see `NoneType`)
STATE VALUE PREFIX: 2024-02-23 12:12:49.374857 (I write current timestamp + some heavy string to demonstrate memory growth)
You can see in the snippet that it's been more than an hour since the state was created, but it's still there.
Does anyone have a working pyflink setup with TTL he can share? Do you have any ideas what I can do to make it work?
Slack Conversation