fix(pgp): throttle trust-db rewrite in RNPPGPHandler::locked_timeStampKey#326
Open
jolavillette wants to merge 1 commit into
Open
fix(pgp): throttle trust-db rewrite in RNPPGPHandler::locked_timeStampKey#326jolavillette wants to merge 1 commit into
jolavillette wants to merge 1 commit into
Conversation
…pKey locked_timeStampKey() is called on every PGP key usage, notably from RNPPGPHandler::VerifySignBin() which runs on every GXS identity validation (p3IdService::pgphash_process -> checkId) and every connection. It updated the key's in-memory usage timestamp AND flagged _trustdb_changed on every call. Because of that, the whole private trust database was rewritten by locked_syncTrustDatabase() on essentially every AuthGPG tick, its file mtime bumped, and then re-read in full (thousands of trust packets) a few seconds later. On a node with many keys this produced a "Detected change on disk of trust database" + full reload every ~10-30s indefinitely (hundreds of times per session), wasting CPU and flooding the log. OpenPGPSDKHandler already throttles this exact update to once per hour; the rnp port had dropped the throttle. Restore it: keep updating the in-memory _time_stamp on every call (cheap), but only set _trustdb_changed at most once per hour. The on-disk trust database is then rewritten ~once per hour instead of constantly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
983eb81 to
089b66e
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fix(pgp): throttle trust-db rewrite in RNPPGPHandler::locked_timeStampKey
locked_timeStampKey() is called on every PGP key usage, notably from RNPPGPHandler::VerifySignBin() which runs on every GXS identity validation (p3IdService::pgphash_process -> checkId) and every connection. It updated the key's in-memory usage timestamp AND flagged _trustdb_changed on every call.
Because of that, the whole private trust database was rewritten by locked_syncTrustDatabase() on essentially every AuthGPG tick, its file mtime bumped, and then re-read in full (thousands of trust packets) a few seconds later. On a node with many keys this produced a "Detected change on disk of trust database" + full reload every ~10-30s indefinitely (hundreds of times per session), wasting CPU and flooding the log.
OpenPGPSDKHandler already throttles this exact update to once per hour; the rnp port had dropped the throttle. Restore it: keep updating the in-memory _time_stamp on every call (cheap), but only set _trustdb_changed at most once per hour. The on-disk trust database is then rewritten ~once per hour instead of constantly.