Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete after insert #174

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft

Delete after insert #174

wants to merge 11 commits into from

Conversation

ePaul
Copy link
Member

@ePaul ePaul commented Jul 28, 2023

(This includes the changes from #171, #173, #176, #175 and builds on top. These should likely be merged first, then this one gets smaller. Implements parts of #170.)

This introduces an optional "delete-after-insert" mode. In this mode, events stored into the database will be immediately deleted.

The purpose of this is to connect the eventlog table to Fabric Event Stream's Debezium-connector (this is a Zalando-internal project), which will read the events from the logical replication log and takes care of sending them out to Nakadi.

Relevant changes:

TODO:

  • actually try this out – it seems to work locally in an example project I made. I was not able to deploy this to a cluster yet, as the corresponding change to FES is not yet deployed.

@ePaul ePaul added spring-boot-2 Issues/PRs which only apply to the Spring-Boot 2 versions (Releases 20.*+) persistence everything around DB access labels Jul 28, 2023
@ePaul ePaul force-pushed the delete-after-insert branch from 0ec1b31 to a7e30b3 Compare July 28, 2023 19:34
@ePaul ePaul force-pushed the delete-after-insert branch 2 times, most recently from 7b6d8fc to 87e711c Compare August 10, 2023 12:28
@ePaul ePaul added auto-configuration everything about the auto-configuration features nakadi-submission labels Aug 10, 2023
Comment on lines +68 to +82
/**
* Persists and immediately deletes some event log entries.
* This is meant to be used together with infrastructure listening to a logical DB replication stream.
* <p><b>Implementer's note:</b> The default implementation just calls {@link #persist(Collection)}
* and {@link #delete(Collection)} and will only work if {@code persist} stores back the IDs into the objects
* (which is not part of the contract). If that's not the case, this methods needs to be overridden to
* implement it in a different way.
* </p>
* (The implementation in Nakadi-Producer Spring Boot starter reimplements this method.)
* @param eventLogs the event log entries to be persisted and deleted.
*/
default void persistAndDelete(Collection<EventLog> eventLogs) {
persist(eventLogs);
delete(eventLogs);
};
Copy link
Member Author

@ePaul ePaul Aug 10, 2023

Choose a reason for hiding this comment

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

I've added this default implementation so we can stay compatible with applications which don't use the spring boot starter, but implement this manually. But it doesn't actually work, unless the persist method is implemented in a way that it fills the id field. So I wonder whether we should just skip the default implementation here?
Alternatively, we could have it throw an exception.

This is only relevant in the case that someone doesn't use the spring-boot-starter, but uses their own repository implementation. I know of exactly one app which did this (because it didn't use spring-boot), and that was decommissioned two years ago (and only ever got to version 4.3.0). Not sure we even need to worry about this.

@ePaul ePaul force-pushed the delete-after-insert branch 2 times, most recently from 26fe4a3 to 41affd2 Compare August 15, 2023 15:19
@ePaul ePaul force-pushed the delete-after-insert branch from b057e3e to f750c20 Compare August 22, 2023 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-configuration everything about the auto-configuration features nakadi-submission persistence everything around DB access spring-boot-2 Issues/PRs which only apply to the Spring-Boot 2 versions (Releases 20.*+)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant