Skip to content

Filter out-of-order/duplicate graph events#16

Open
pallakartheekreddy wants to merge 3 commits intodevelopfrom
cdc-issue
Open

Filter out-of-order/duplicate graph events#16
pallakartheekreddy wants to merge 3 commits intodevelopfrom
cdc-issue

Conversation

@pallakartheekreddy
Copy link
Copy Markdown

Add a lastUpdatedCache map and a shouldProcessEvent(...) helper to drop events that are older than or equal to the last-processed lastUpdatedOn for the same nodeUniqueId. The processor now calls shouldProcessEvent before sending events to sinks; accepted events update the cache, while dropped events are logged at debug level. This prevents duplicate or out-of-order event emissions when timestamps are present.

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Type of change

Please choose appropriate options.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes in the below checkboxes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Ran Test A
  • Ran Test B

Test Configuration:

  • Software versions:
  • Hardware versions:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Add a lastUpdatedCache map and a shouldProcessEvent(...) helper to drop events that are older than or equal to the last-processed lastUpdatedOn for the same nodeUniqueId. The processor now calls shouldProcessEvent before sending events to sinks; accepted events update the cache, while dropped events are logged at debug level. This prevents duplicate or out-of-order event emissions when timestamps are present.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 18, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a3bcea3e-b22e-461d-83f5-c4fe0d5c4d8b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cdc-issue

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds in-memory filtering to prevent emitting out-of-order or duplicate JanusGraph CDC events by tracking the last processed lastUpdatedOn timestamp per nodeUniqueId. It addresses the issue of duplicate/out-of-order event emissions when timestamps are present in the converted event payload.

Changes:

  • Introduces a lastUpdatedCache (nodeUniqueId → last processed lastUpdatedOn epoch ms).
  • Adds shouldProcessEvent(...) to drop events whose lastUpdatedOn is <= the cached value (and logs dropped events at debug).
  • Hooks the new filter into processVertexChange(...) so filtering happens before dispatch to sinks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

pallakartheekreddy and others added 2 commits March 23, 2026 14:24
Make lastUpdatedCache a synchronized LRU (LinkedHashMap) with MAX_CACHE_SIZE=10_000 to prevent unbounded heap growth. Modify processing flow so events are only recorded in the cache after a confirmed successful send: sendEventToSinks now returns boolean, shouldProcessEvent no longer mutates the cache, and a new updateLastUpdatedCache helper advances the cache after success. Also clear the cache on stop. Add /src to .gitignore. These changes reduce lost retries on serialization/send failures and cap memory usage.
- Remove dead hasStatusAttribute method (never called)
- Cache addedVertices/removedVertices sets before UPDATE loop to avoid
  repeated getVertices() calls and re-consuming single-use iterables
- Downgrade per-edge relation logging from INFO to DEBUG to reduce noise
- Fix typo: INitialize -> Initialize in comment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants