Skip to content

first draft for concurrency using an approach at the database level - #12

Merged
J0nasMayr merged 13 commits into
mainfrom
ab-536-emailservice-job-is-running-on-each-pod-and-could
Aug 20, 2026
Merged

first draft for concurrency using an approach at the database level#12
J0nasMayr merged 13 commits into
mainfrom
ab-536-emailservice-job-is-running-on-each-pod-and-could

Conversation

@J0nasMayr

@J0nasMayr J0nasMayr commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Changes:

  • Fix pod-concurrency using db-level atomic compare-and-set
  • Add exponential backoff logic for failing sends with a threshold of maximum tries
  • make public facing sendOrFail not retry on failure
  • Refactor entity Email adding new fields and embedding logically connected ones

@J0nasMayr
J0nasMayr requested a review from SirCotare August 12, 2026 09:47
@J0nasMayr J0nasMayr self-assigned this Aug 12, 2026
@J0nasMayr
J0nasMayr removed the request for review from SirCotare August 14, 2026 07:53
@J0nasMayr
J0nasMayr marked this pull request as draft August 14, 2026 07:55
@J0nasMayr
J0nasMayr marked this pull request as ready for review August 14, 2026 14:20
@J0nasMayr

J0nasMayr commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

@SirCotare I think the approach I went with here fits better than com.translog.transcon.job.DistributedLockService since we are talking about a single job here which is sending emails. In this case the locking granularity should be per row, not per job. Using com.translog.transcon.job.DistributedLockService we would have to have a distinct lockKey for each email (i.e. we would have to add the Email-id to the lockKey). That would require each scheduled run of sending nqueued emails to create/hold n locks. I do not think that that is very clean/performant.
If you think that I should go with it anyways, just say the word.

@J0nasMayr
J0nasMayr requested a review from SirCotare August 14, 2026 15:00
@alexlanz
alexlanz requested review from mmalfertheiner and removed request for SirCotare August 19, 2026 07:07

@mmalfertheiner mmalfertheiner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  • Followup task: The Cleanup scheduler is not yet multi pod safe

Comment thread readme.md Outdated
Comment thread readme.md Outdated
@J0nasMayr

Copy link
Copy Markdown
Contributor Author

@mmalfertheiner Andreas and I agreed to have a try-catch block in case the .save() fails because in that case we cannot do anything anyways. The actual email-send and the .save() after to set the mail to something other than SENDING will always be independent statements and hence if the .save() fails we cannot do any more than logging it...

@mmalfertheiner mmalfertheiner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well done! LGTM

@J0nasMayr
J0nasMayr merged commit e37c8a7 into main Aug 20, 2026
1 check passed
@J0nasMayr
J0nasMayr deleted the ab-536-emailservice-job-is-running-on-each-pod-and-could branch August 20, 2026 08:34
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