Skip to content

CIRC-2699 Resync anonymization preferences nightly - #1709

Merged
slaemmer merged 11 commits into
masterfrom
CIRC-2699-resync-preferences
Nov 9, 2026
Merged

slaemmer merged 11 commits into
masterfrom
CIRC-2699-resync-preferences

Conversation

@slaemmer

@slaemmer slaemmer commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

CIRC-2699
Part of UXPROD-5562
Design page

Requires folio-org/mod-circulation-storage#606 (interface loan-anonymization-preference-storage 1.0).

Purpose

The preference table in mod-circulation-storage is kept in sync via Kafka events. In some rare cases these Kafka events might not be registered. Then loans could be anonymized against the user's choice, which can't be undone. A nightly resync updates the table from mod-users in case these really rare edge cases occur.

Open questions

  • Should users interface requirement be bumped?
  • Should the timer job check the users each night (as is currently) or should it check whether the feature is disabled and skip the user call in that case? Happy to adjust this.

Approach

  • Nightly timer fetches users with a preference from mod-users at 02:00 CET also while the feature is disabled
  • Pages by id, so no user is skipped
  • Writes only after all pages were fetched
  • Replaces the copy in mod-circulation-storage
  • users requirement stays 14.2 15.0 16.0, although the field only exists since users 16.6 (MODUSERS-600): against an older mod-users the query finds nobody and the table is emptied, which is correct there, as no user can have a preference.
  • Measured locally (Testcontainers, real mod-users): 1,000,000 users with 100,000 preferences take about 10 s to fetch and 1 s to write; every call stays well below the 20 s HTTP client timeout.

- Nightly timer fetches users with a preference from mod-users
- Pages by id, so no user is skipped
- Writes only after all pages were fetched
- Replaces the copy in mod-circulation-storage
@slaemmer
slaemmer force-pushed the CIRC-2699-resync-preferences branch from 688dc04 to cf62ae0 Compare October 29, 2026 11:02
@slaemmer
slaemmer marked this pull request as ready for review October 29, 2026 11:37
@slaemmer
slaemmer requested review from a team and alexanderkurash October 29, 2026 11:37
@charismatic-claire

charismatic-claire commented Nov 3, 2026 •

Copy link
Copy Markdown

Nightly timer fetches users with a preference from mod-users at 02:00 CET also while the feature is disabled

--> Shouldn't that be a preference the admins could set. It depends heavily on your timezone when "nightly" is right? So for some libraries this could run at the middle of the day, which might not be preferable, right?

@charismatic-claire

Copy link
Copy Markdown

Measured locally (Testcontainers, real mod-users): 1,000,000 users with 100,000 preferences take about 10 s to fetch and 1 s to write; every call stays well below the 20 s HTTP client timeout.

--> One question here: Is this a blocking operation, so the whole system is unresponsive for the time this is running, or does this run asynchronously in the background?

@slaemmer

slaemmer commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Regarding your questions:

  1. I followed the usual pattern of how FOLIO handles timed background jobs. They usually run at some point in the night CET time (e.g. the digital reminders in mod-circulation at 00:01). They usually are non configurable. It also is a relatively small job and runs in a few seconds and also - and this brings me to your second question
  2. it runs in the background and is asynchronous. mod-scheduler (or Okapi) sends the request at the specified time and mod circulation handles it like any other request.

@charismatic-claire charismatic-claire left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I basically have questions and have some code style improvements suggested. Let me know what you think :)

@sonarqubecloud

sonarqubecloud Bot commented Nov 3, 2026

Copy link
Copy Markdown

}

private CompletableFuture<Result<List<UserLoanAnonymizationPreference>>>
fetchAllUserSpecificPreferences(String afterId, List<UserLoanAnonymizationPreference> fetched) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That's weirdly formatted. Is there an auto-formatter we could run?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nothing I know of. No spotless etc. Will indent the line manually though.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 Lame there isn't an formatter / linter.

@charismatic-claire charismatic-claire left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fine from my end.

@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@slaemmer
slaemmer merged commit 651f258 into master Nov 9, 2026
18 checks passed
@slaemmer
slaemmer deleted the CIRC-2699-resync-preferences branch November 9, 2026 14:21
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