Skip to content

Fix: timeline ttl expiry - #61

Merged
DKZed merged 2 commits into
aerospike:mainfrom
adarshprabhu03:fix-timeline-ttl-expiry
Jun 29, 2026
Merged

Fix: timeline ttl expiry#61
DKZed merged 2 commits into
aerospike:mainfrom
adarshprabhu03:fix-timeline-ttl-expiry

Conversation

@adarshprabhu03

Copy link
Copy Markdown
Contributor

Description

This PR fixes a bug in AerospikeSaver where the __timeline__ metadata record would expire and get deleted by Aerospike even if the associated checkpoints were active and refreshed on reads.

When refresh_on_read is enabled, reading a checkpoint via get_tuple() resets the expiration timer (TTL) for individual checkpoints and the __latest__ record, but never touched the __timeline__ record. After the default TTL elapsed, the timeline record would expire. This resulted in history lookups (list()) returning empty lists even though active checkpoints still existed in the database.

Changes Made

  • packages/langgraph-checkpoint-aerospike/langgraph/checkpoint/aerospike/saver.py:
    • Updated get_tuple() to retrieve/touch the __timeline__ record using the configured read-touch policy (read_touch_ttl_percent: 100) if self._refresh_on_read is enabled.
  • packages/langgraph-checkpoint-aerospike/tests/test_ttl_behavior.py:
    • Added test_timeline_refreshes_on_get to verify TTL extension logic against an active Aerospike server.
    • Added test_timeline_refreshes_on_get_mocked to verify the read-touch behavior offline using unittest.mock.

Testing

  • Offline Mocked Unit Test: Created and successfully ran test_timeline_refreshes_on_get_mocked to verify that client.get is called on the timeline record key with the correct policy {"read_touch_ttl_percent": 100} on retrieval.
  • Code Quality: Ran ruff check and ruff format to ensure compliance with the repository style.
  • Static Type Checking: Ran mypy across the package (passed with no issues).

Screenshots (if applicable)

N/A

Additional Notes

This fix ensures that the checkpointer maintains consistency between the active checkpoints and the metadata timeline indexing under sliding TTL policies.

@adarshprabhu03

adarshprabhu03 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Hi @DKZed @sshettigar-aerospike @havvari-V0 , could you please take a look at this PR? It fixes the silent timeline record expiry bug when refresh_on_read is enabled in AerospikeSaver. I have also added offline mocked test cases to verify the read-touch behavior. Thanks!

@adarshprabhu03

Copy link
Copy Markdown
Contributor Author

For additional confidence, I also ran an end-to-end verification against a local Aerospike instance with nsup-period=30 to exercise the TTL refresh path.

Before patch

  • TTL: 52s → 51s after get_tuple (no refresh; bug confirmed)

After patch

  • TTL: 52s → 59s after get_tuple (TTL refreshed back to approximately the full TTL)

This complements the mocked unit test and confirms that the read-touch policy correctly refreshes the TTL on real Aerospike records.

@DKZed DKZed changed the title Fix timeline ttl expiry Fix: timeline ttl expiry Jun 29, 2026

@DKZed DKZed left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for finding this. Upon reviewing there are other TTL issues in a similar vein that I will address!

@DKZed
DKZed merged commit 0934a79 into aerospike:main Jun 29, 2026
5 of 7 checks passed
@lyndonbauto

Copy link
Copy Markdown
Collaborator

Hey @adarshprabhu03, I am really interested in what you're using Aerospike for in the AI space as we are actively increasing our supported frameworks.

If you feel like it and are able to share, I would love the feedback and see if we can use it to influence our future work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants