-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add locking in cleanup #23
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a1be640
feat: add locking in cleanup
chris-asl 732ac20
feat: accept cleanup locks provider in builder
chris-asl 9577c9b
chore: update REAMDE & document `SimpleOutboxHandler`
chris-asl 9d4d65e
chore: add UPGRADING guide
chris-asl fba98cb
chore: bump core lib version to 2.0.0
chris-asl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Upgrade Guide | ||
|
||
## v.2.x.x | ||
|
||
### v.2.0.0 - Completed outbox items cleanup coordination | ||
|
||
Release 2.0.0 introduces coordination in the cleanup process across instances using locks. | ||
|
||
#### `TransactionalOutboxBuilder#withLocksProvider` has been removed in favor of `withMonitorLocksProvider` | ||
The reason for this breaking change was the need to introduce a different locks provider for the completed outbox items cleanup process. | ||
We could reuse the same locks provider for both the monitor and cleanup process, but this would entail serialized execution of the two processes, which was not desirable. | ||
The requirement for the new locks provider is solely to be independent of the locks provider used in the monitor process. | ||
For example, if the locks provider implementation is using Postgres advisory locks, the monitor and the cleanup locks should use a different lock identifier. | ||
|
||
**Required changes** | ||
The `TransactionalOutboxBuilder` call needs to be updated from | ||
```kotlin | ||
TransactionalOutboxBuilder | ||
.make(clock) | ||
.withHandlers(outboxHandlers) | ||
.withLocksProvider(locksProvider) | ||
.withStore(outboxStore) | ||
.build() | ||
``` | ||
to | ||
```kotlin | ||
TransactionalOutboxBuilder | ||
.make(clock) | ||
.withHandlers(outboxHandlers) | ||
.withMonitorLocksProvider(PostgresOutboxLocksProvider(LOCKS_MONITOR_ID)) | ||
.withCleanupLocksProvider(PostgresOutboxLocksProvider(LOCKS_CLEANUP_ID)) | ||
.withStore(outboxStore) | ||
.build() | ||
``` | ||
N.B.: The above assumes that the locks provider implementation is using Postgres advisory locks. | ||
|
||
## v.1.x.x | ||
|
||
### v.1.0.0 - Completed outbox items cleanup | ||
|
||
Release 1.0 introduces a cleanup process for the outbox items that have been successfully processed, thus reducing the size of the outbox table, which can grow quite large. | ||
When the outbox items are processes successfully, in addition to be marked as completed, their `OutboxItem.deleteAfter` field is set to `now() + retentionPeriod`. | ||
The cleanup process, like monitor, should be run periodically, depending on your needs. Once run, it deletes the completed | ||
outbox items whose `deleteAfter` is earlier than the current time. | ||
|
||
It is advisable to manually delete the already completed outbox items before upgrading to 1.0.0, as the cleanup process | ||
will issue a deletion, which may be quite heavy in terms of I/O operations, hence timeouts may occur on the first run. | ||
|
||
**Required changes** | ||
In the `OutboxStore` implementing class, the `deleteCompletedItems(now: Instant)` method needs to be implemented. | ||
The method should simply delete the outbox items with status `COMPLETED` with a `deleteAfter` earlier than the provided `now` parameter. | ||
|
||
Finally, the retention duration period can be defined per outbox handler for flexibility. | ||
A new `OutboxHandler` method has been added `getRetentionDuration(): Duration` which should return the retention period for the outbox items of the handler. | ||
Feel free to look the [SimpleOutboxHandler](./core/src/main/kotlin/io/github/bluegroundltd/outbox/SimpleOutboxHandler.kt) for an example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also add some notes on how users should upgrade from
1.0.0
to2.0.0
?Or we should add this to the release tag after the release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that's a nice idea!
In this case though, the upgrade only requires the addition of the locks provider call and the rename of the current function. The
TransactionalBuilder
API is guiding the user via the fluent interface. I've also kinda updated the docs here.Do you possibly mean adding a migration guide? Like
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9d4d65e 👀