-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add persistent dedup cache for message hashes (#3130)
<!--- Provide a general summary of your changes in the Title above --> ## Description - Added a persistent dedup message hash cache for messages that will be trimmed to capacity every 5 minutes: - dedup cache size configurable for users; - trimming period configurable. - Added a unit test to test the dedup cache operation. ## Motivation and Context A recent stress test highlighted duplicate stages of transaction messages still being sent hours after a transaction has been mined, evoking a flood of SAF messages each time. A wallet also had no way of knowing which transactional message had been processed already. The dedup cache was changed from _time-to-live_ to being _persistent_. ## How Has This Been Tested? - System-level testing under stress test conditions. - New unit test. ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> * [X] I'm merging against the `development` branch. * [X] I have squashed my commits into a single commit.
- Loading branch information
Showing
17 changed files
with
372 additions
and
41 deletions.
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
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
1 change: 1 addition & 0 deletions
1
comms/dht/migrations/2021-07-23-162902_add_dedup_cache/down.sql
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 @@ | ||
DROP TABLE IF EXISTS dedup_cache; |
10 changes: 10 additions & 0 deletions
10
comms/dht/migrations/2021-07-23-162902_add_dedup_cache/up.sql
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,10 @@ | ||
CREATE TABLE dedup_cache ( | ||
id INTEGER NOT NULL PRIMARY KEY, | ||
body_hash TEXT NOT NULL, | ||
sender_public_key TEXT NOT NULL, | ||
number_of_hits INT NOT NULL, | ||
stored_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
last_hit_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP | ||
); | ||
|
||
CREATE UNIQUE INDEX uidx_dedup_cache_body_hash ON dedup_cache (body_hash); |
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.