Skip to content
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

Node becomes unresponsive causing all peers to be dropped #3143

Closed
wiz opened this issue Aug 27, 2019 · 15 comments
Closed

Node becomes unresponsive causing all peers to be dropped #3143

wiz opened this issue Aug 27, 2019 · 15 comments

Comments

@wiz
Copy link
Contributor

wiz commented Aug 27, 2019

Here is one example where node was completely unresponsive for 30+ seconds while processing these events

Aug-27 08:01:28.521 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Sun Jun 09 02:06:48 JST 2019, proposalTxId=adfe3550b36d8d644fb600ec43b9eeb1ebbc03946631a2d8c93811812e61c3f8, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:29.165 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Wed Jun 05 04:17:02 JST 2019, proposalTxId=dc561b2cf7ebc1636c986db8d710e14e01e0072bdf1a0b621094d3c2ce4a4276, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:29.782 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Tue May 07 06:46:12 JST 2019, proposalTxId=583d4bc4e9bd7d1b0b6bfa47ce542dd33deea9febd7e26ac31de0ad18b39e9fb, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:30.386 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Wed May 08 06:19:09 JST 2019, proposalTxId=1fbc48fc1052287dcd33da555184a3e095bd089244b2375cf1a4a3afe67c2367, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:30.957 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Tue Apr 16 02:33:47 JST 2019, proposalTxId=45f972f4b169596d2d68e2d24b6c878c6e9fd53b7029dfb26ee5372d130b2c58, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:31.509 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Wed Jun 26 18:07:42 JST 2019, proposalTxId=078ea6a58b49f1f63d231c0fdc6f58958eb2e22b8dbca4a23e0f81081753f82e, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:32.084 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Tue Apr 16 05:13:35 JST 2019, proposalTxId=268c2d5774860076042eddafa272c7a21b5c9e2142523d26e0b5cfbe2920c550, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:32.694 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Fri May 10 07:43:06 JST 2019, proposalTxId=bcb3fe082ef6ebf61ce3fe25831465d8d4e896a46c9d2d4f4cb0bbb9d3d7407c, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:33.254 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Wed May 08 06:23:06 JST 2019, proposalTxId=1aacf40f84f8019f6d3f82d0736fc956c3eb3056cfdc4193d95af698b35dc2a9, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:33.825 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Wed May 01 00:14:45 JST 2019, proposalTxId=005e1c21b46365dfddd85f16cbf9295352fda2b16ac4902572f50805fb3c1661, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:34.405 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Thu May 09 03:40:11 JST 2019, proposalTxId=478bcc32a29da85ac13cf8a745791a9eae952407538a86020484f9d6fe0d2cd3, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:34.923 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Thu May 09 15:15:48 JST 2019, proposalTxId=7b2a461862c6c775dbbc432428972482534564ef43f90e119c1bedca7279d440, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:35.475 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Fri May 10 07:02:07 JST 2019, proposalTxId=48988479268a4a88c560bc2a24a31310c09346abf0a172b2a9064a9545bf00d6, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:36.060 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Sat Jun 08 09:57:12 JST 2019, proposalTxId=178793433fb5e120678099fff2121ec45c073a769ff76865aa767339e41405eb, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:36.631 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Sun May 05 18:09:16 JST 2019, proposalTxId=3d38239a7b54fb2230ee57d5b91bdfcab968dc99c97a591c88a1d2b8d254a2c3, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:37.190 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Thu May 02 18:34:13 JST 2019, proposalTxId=dd343de1ea38cddf0c1bd29c6f03a0ffe208c8b359cd1860acd0b8390c3bc598, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:37.757 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Mon May 06 08:37:44 JST 2019, proposalTxId=6e3c863eb157b7c9c63992a7dbf3e29971a5321e4abcf507c63ee1a1c2f1f8f8, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:38.319 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Wed May 22 17:19:06 JST 2019, proposalTxId=15ebb38e62d555616b39909312cab5bb0d4036001692a7b75bc6d5cd520bdd59, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:38.858 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Sun Jun 09 18:55:17 JST 2019, proposalTxId=9d17e4bca77789984f724f3868d60b6c622614847734717c1eb39a2a12c93e14, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:39.385 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Sat May 04 21:44:44 JST 2019, proposalTxId=2f9b12b0cfa4d342b9a5caa485c2cba28d126725358ed7afd299ccc9a3adc97f, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:39.906 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Sun Jun 09 14:51:54 JST 2019, proposalTxId=7981494bde3f1d3afe7e0e9117063c0c59800b09519fe5a12409f485d923fb35, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:40.393 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Sun Jun 09 21:42:34 JST 2019, proposalTxId=4b57147cf8e4667404e17eca6aed04958872b07985fe2925cf593611d34d7337, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:40.891 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Wed May 22 18:41:12 JST 2019, proposalTxId=5a40b4763fa7373053f8320e8cca0d8159e7f5ef0b3e6674ca5b1ca44b8bfada, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:41.422 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Wed May 08 00:20:36 JST 2019, proposalTxId=a0bb2ba875640777aa15a09b890d082e7a8ba0ecd3d2ee273642a68078925fc7, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:41.994 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Wed Jun 05 20:44:50 JST 2019, proposalTxId=b686aa4b63938c1f4c09f57380f31c9f2b9a1fbde55931bb8d097cf46762297b, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:42.570 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Wed Jun 05 21:34:37 JST 2019, proposalTxId=23d37d25179887fdd8824284cc4f7f71405a6c51b04095856a12da764fc45f0b, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:43.175 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Tue Apr 16 02:33:25 JST 2019, proposalTxId=ac7284bd48d6fb16929e51a1727d0f86ec70a7b39484b3908432257913352ed7, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:43.745 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Thu May 09 07:04:05 JST 2019, proposalTxId=6052bb8615f98dade231b31f761ffd6cbbc6d834ca1a77c8bc0bb8ba3b454f55, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:44.313 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Sat May 04 21:45:51 JST 2019, proposalTxId=ce815d462f70d5cc5ed5fdef3c0ac4fa5670cbfbd31aa8678d82bab3f3cb384d, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:44.789 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Tue Apr 16 06:11:45 JST 2019, proposalTxId=3480075bd62cc344a668949e6b8025779db5a4778bd1f6a7fc6a404eb38a3f3d, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:45.293 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Sun May 05 17:43:04 JST 2019, proposalTxId=53734e0f315d4d262aa0d0fad27354263e5055d01a66be25c4ab8d9c57a044bc, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:45.808 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Thu Jun 06 17:53:04 JST 2019, proposalTxId=1e1f13d434eb65fd236c674a825a74750ab752d5402e8fc811d32b716492b447, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:46.319 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Tue Apr 16 06:13:27 JST 2019, proposalTxId=cc5bd8a0b20569eb92306579a191ed615d890b6e328796cd5ab0e19416c8527e, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:46.794 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Thu May 23 10:35:14 JST 2019, proposalTxId=a6a3863ddc0fdb02f2e2de75990cb6bb386b7922f34d30972d3e223aa0ad5fe4, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:47.303 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Fri Jun 07 00:29:17 JST 2019, proposalTxId=1a4de9dd6c8a42f418e42ba9aaf08c43ca79b697fc1510a842e4743149845212, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:47.805 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Wed May 08 22:12:50 JST 2019, proposalTxId=5c0763c2ef9fd468b9d023f8a257a4c0443c496387ce841deb78549671af08ea, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:48.309 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Sun Jun 09 05:18:03 JST 2019, proposalTxId=cf8815d4297696f2cfafcd0fee6a2f89249718957f07a316c5b9cee5e7b5fb81, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:48.771 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Fri May 10 00:23:50 JST 2019, proposalTxId=0afb214897681179f1902e504df43bacebb807438e72c4384f72349a1bf4ecd7, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:49.327 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Tue Apr 16 02:32:29 JST 2019, proposalTxId=1e855c4e525937e595029caf4c35701502ca359351e0537599ce517f953c6fce, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:49.863 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Wed Jun 05 21:33:25 JST 2019, proposalTxId=d80173d28c328558017619cb7619f915c7bda963e9eaa3885d7f6aa33b6c1448, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:50.358 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Fri Jun 07 05:53:34 JST 2019, proposalTxId=ce348b9dc336e5effa853c55ea1141c29a0282152bfd46895d79bb40ef34f73d, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:50.988 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Mon May 06 08:49:19 JST 2019, proposalTxId=6d9782e2f548bdf731336bf3ccd99c0220cb715fab524cf518d768d97d27d97f, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:51.663 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Sat May 04 12:34:16 JST 2019, proposalTxId=6a95c98247d7817f3c0661e9cb6b3c25cf3169cce1f698b496cddb224e61d1a4, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:52.244 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Sat Jun 08 07:39:31 JST 2019, proposalTxId=363fe90efbe71368b4783d85f41c5579bd44e12efce2fa8d7958ba7cc3728cfe, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
Aug-27 08:01:52.932 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a remove request for a TempProposalPayload and have removed the proposal from our list. proposal creation date=Sat Jun 08 08:38:18 JST 2019, proposalTxId=bf1825956b83d1e4d66a50414f9ac8ed5fd14f0c8441dcb0b100c64ae6947960, inPhase=true, txInPastCycle=true, unconfirmedOrNonBsqTx=false 
@battleofwizards
Copy link
Contributor

battleofwizards commented Aug 27, 2019

I did have this issue as well.

@ripcurlx
Copy link
Contributor

It seems to be as if they are all unique proposals remove requests. In general that shouldn't degrade the performance just having this many proposals to be removed from your local store. But it might trigger some complex UI update logic for each removal. I have to look into this in more detail.

@wiz
Copy link
Contributor Author

wiz commented Aug 27, 2019

It's happening more and more frequently, almost feels like an attack.

@ripcurlx
Copy link
Contributor

ripcurlx commented Aug 27, 2019

Do you see this performance problems, when you are in the DAO section or this happening without being there? I just want to rule out if it is a problem in the ProposalsView which listens to the changes triggered by this or if it's a non-ui code issue already.

@wiz
Copy link
Contributor Author

wiz commented Aug 27, 2019

I've seen it reproduce multiple times today while on the Funds -> Send Bitcoin screen

@ripcurlx
Copy link
Contributor

I just tested one instance that wasn't synced for a while and the application froze while receiving all blocks

...
Aug.-27 11:32:12.313 [JavaFX Application Thread] INFO  b.core.dao.node.lite.LiteNode: New block at height 591926 from bsqWalletService 
...

Because of the freezing of the app lots all connections, but the client reconnected afterwards without any problems.
While parsing the blocks

...
Aug.-27 11:33:03.447 [JavaFX Application Thread] INFO  b.c.d.node.parser.BlockParser: Parsing 3 transactions at block height 587628 took 8 ms 
...

the app became responsive again and I also received the block of remove requests. Being in the market>offer book didn't cause any connection drops for me so far.

@wiz
Copy link
Contributor Author

wiz commented Aug 27, 2019

I've been seeing this happen on my production desktop macos app, which is fully synced and usually very well-connected to many P2P peers, as well as my development Linux app, and I believe it's also happening on my production seednode 😓

To be clear, the warning message that all P2P peers has been lost does appear each time.
Screen Shot 2019-08-27 at 4 03 15

@ripcurlx
Copy link
Contributor

After a restart of my synced node I received the removal request while being in the market>offer book and it froze my app this time. It didn't disconnect me, but I'm surprised that this consumes so much CPU removing the proposals.

@ripcurlx
Copy link
Contributor

Ok - I can reproduce it each time. When the remove requests are coming in while using the app, it completely freezes the client, which causes depending on the performance of your instance probably also connection drops if it takes too long to parse through all these removal requests. @sqrrm @ManfredKarrer Do you have an idea how we could improve the handling of theses remove requests? Parsing them maybe one by one with a delay (if the required bits of the code are necessary for validation)?

@wiz
Copy link
Contributor Author

wiz commented Aug 27, 2019

Seems UI thread related according to this log print

Aug-27 08:01:54.067 [JavaFX Application Thread] INFO  bisq.common.ClockWatcher: We have been in standby mode for 25 sec 

@wiz
Copy link
Contributor Author

wiz commented Aug 27, 2019

Also take a look how seednode response times have recently been going into the minutes as well https://monitor.bisq.network/d/wTDl6T_iz/p2p-stats?orgId=1&fullscreen&panelId=10&refresh=30s&from=now-24h&to=now

Screen Shot 2019-08-27 at 19 26 12

@ManfredKarrer
Copy link
Contributor

Looking into it. TempProposalStore should not be added to resources anymore. Each new client gets the old data and then need to remove it.
Processing for 1 removal takes 200 ms. So that is definitely too long. Looking into the consumers, its probably the ProposalListPresentation class...

@ManfredKarrer
Copy link
Contributor

The validation calls are slow as they get called each time the list changed on each element. I will optimize that so that the list only gets updated once the batch processing is done.

ripcurlx added a commit that referenced this issue Aug 27, 2019
Improve TempProposal processing (fixes #3143)
wiz added a commit to wiz/bisq that referenced this issue Aug 28, 2019
@wiz
Copy link
Contributor Author

wiz commented Sep 2, 2019

Reproduced again on master (HEAD=9047ff17a2f2a36236895aaeaaea8300ed0347d4), node was stuck for about 17 seconds:

Sep-03 06:56:31.477 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=7b2a461862c6c775dbbc432428972482534564ef43f90e119c1bedca7279d440 
Sep-03 06:56:31.745 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=9d17e4bca77789984f724f3868d60b6c622614847734717c1eb39a2a12c93e14 
Sep-03 06:56:32.204 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=7981494bde3f1d3afe7e0e9117063c0c59800b09519fe5a12409f485d923fb35 
Sep-03 06:56:32.657 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=6a95c98247d7817f3c0661e9cb6b3c25cf3169cce1f698b496cddb224e61d1a4 
Sep-03 06:56:33.069 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=adfe3550b36d8d644fb600ec43b9eeb1ebbc03946631a2d8c93811812e61c3f8 
Sep-03 06:56:33.546 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=6d9782e2f548bdf731336bf3ccd99c0220cb715fab524cf518d768d97d27d97f 
Sep-03 06:56:33.946 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=dc561b2cf7ebc1636c986db8d710e14e01e0072bdf1a0b621094d3c2ce4a4276 
Sep-03 06:56:34.107 [TorControlParser] INFO  o.b.netlayer.tor.Tor: Hidden Service k5nv5kjnpeoolrdp.onion.onion is ready 
Sep-03 06:56:34.126 [Thread-23] INFO  b.n.p2p.network.TorNetworkNode: 
################################################################
Tor hidden service published after 34281 ms. Socked=HiddenServiceSocket[addr=k5nv5kjnpeoolrdp.onion,port=9999]
################################################################ 
Sep-03 06:56:34.414 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=178793433fb5e120678099fff2121ec45c073a769ff76865aa767339e41405eb 
Sep-03 06:56:34.819 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=1fbc48fc1052287dcd33da555184a3e095bd089244b2375cf1a4a3afe67c2367 
Sep-03 06:56:35.092 [TorControlParser] INFO  o.b.netlayer.tor.Tor: Hidden Service k5nv5kjnpeoolrdp.onion.onion is ready 
Sep-03 06:56:35.175 [TorControlParser] INFO  o.b.netlayer.tor.Tor: Hidden Service k5nv5kjnpeoolrdp.onion.onion is ready 
Sep-03 06:56:35.266 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=583d4bc4e9bd7d1b0b6bfa47ce542dd33deea9febd7e26ac31de0ad18b39e9fb 
Sep-03 06:56:35.406 [TorControlParser] INFO  o.b.netlayer.tor.Tor: Hidden Service k5nv5kjnpeoolrdp.onion.onion is ready 
Sep-03 06:56:35.755 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=478bcc32a29da85ac13cf8a745791a9eae952407538a86020484f9d6fe0d2cd3 
Sep-03 06:56:36.147 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=a6a3863ddc0fdb02f2e2de75990cb6bb386b7922f34d30972d3e223aa0ad5fe4 
Sep-03 06:56:36.263 [TorControlParser] INFO  o.b.netlayer.tor.Tor: Hidden Service k5nv5kjnpeoolrdp.onion.onion is ready 
Sep-03 06:56:36.533 [TorControlParser] INFO  o.b.netlayer.tor.Tor: Hidden Service k5nv5kjnpeoolrdp.onion.onion is ready 
Sep-03 06:56:36.649 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=cf8815d4297696f2cfafcd0fee6a2f89249718957f07a316c5b9cee5e7b5fb81 
Sep-03 06:56:37.062 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=363fe90efbe71368b4783d85f41c5579bd44e12efce2fa8d7958ba7cc3728cfe 
Sep-03 06:56:37.456 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=5a40b4763fa7373053f8320e8cca0d8159e7f5ef0b3e6674ca5b1ca44b8bfada 
Sep-03 06:56:37.872 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=cc5bd8a0b20569eb92306579a191ed615d890b6e328796cd5ab0e19416c8527e 
Sep-03 06:56:38.259 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=1e855c4e525937e595029caf4c35701502ca359351e0537599ce517f953c6fce 
Sep-03 06:56:38.625 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=45f972f4b169596d2d68e2d24b6c878c6e9fd53b7029dfb26ee5372d130b2c58 
Sep-03 06:56:39.044 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=1a4de9dd6c8a42f418e42ba9aaf08c43ca79b697fc1510a842e4743149845212 
Sep-03 06:56:39.399 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=268c2d5774860076042eddafa272c7a21b5c9e2142523d26e0b5cfbe2920c550 
Sep-03 06:56:39.784 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=ce348b9dc336e5effa853c55ea1141c29a0282152bfd46895d79bb40ef34f73d 
Sep-03 06:56:40.154 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=1aacf40f84f8019f6d3f82d0736fc956c3eb3056cfdc4193d95af698b35dc2a9 
Sep-03 06:56:40.566 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=0afb214897681179f1902e504df43bacebb807438e72c4384f72349a1bf4ecd7 
Sep-03 06:56:40.989 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=078ea6a58b49f1f63d231c0fdc6f58958eb2e22b8dbca4a23e0f81081753f82e 
Sep-03 06:56:41.410 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=b686aa4b63938c1f4c09f57380f31c9f2b9a1fbde55931bb8d097cf46762297b 
Sep-03 06:56:41.850 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=5c0763c2ef9fd468b9d023f8a257a4c0443c496387ce841deb78549671af08ea 
Sep-03 06:56:42.225 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=d80173d28c328558017619cb7619f915c7bda963e9eaa3885d7f6aa33b6c1448 
Sep-03 06:56:42.635 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=3480075bd62cc344a668949e6b8025779db5a4778bd1f6a7fc6a404eb38a3f3d 
Sep-03 06:56:43.047 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=1e1f13d434eb65fd236c674a825a74750ab752d5402e8fc811d32b716492b447 
Sep-03 06:56:43.443 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=23d37d25179887fdd8824284cc4f7f71405a6c51b04095856a12da764fc45f0b 
Sep-03 06:56:43.834 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=6e3c863eb157b7c9c63992a7dbf3e29971a5321e4abcf507c63ee1a1c2f1f8f8 
Sep-03 06:56:44.201 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=a0bb2ba875640777aa15a09b890d082e7a8ba0ecd3d2ee273642a68078925fc7 
Sep-03 06:56:44.608 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=6052bb8615f98dade231b31f761ffd6cbbc6d834ca1a77c8bc0bb8ba3b454f55 
Sep-03 06:56:45.074 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=464e24d68706c96d96b9764888df44ca81ae8ed43bc181cea13f57b618c2f705 
Sep-03 06:56:45.481 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=4b57147cf8e4667404e17eca6aed04958872b07985fe2925cf593611d34d7337 
Sep-03 06:56:45.896 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=ac7284bd48d6fb16929e51a1727d0f86ec70a7b39484b3908432257913352ed7 
Sep-03 06:56:46.257 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=005e1c21b46365dfddd85f16cbf9295352fda2b16ac4902572f50805fb3c1661 
Sep-03 06:56:46.656 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=15ebb38e62d555616b39909312cab5bb0d4036001692a7b75bc6d5cd520bdd59 
Sep-03 06:56:47.023 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=bf1825956b83d1e4d66a50414f9ac8ed5fd14f0c8441dcb0b100c64ae6947960 
Sep-03 06:56:47.413 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=48988479268a4a88c560bc2a24a31310c09346abf0a172b2a9064a9545bf00d6 
Sep-03 06:56:47.799 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=bcb3fe082ef6ebf61ce3fe25831465d8d4e896a46c9d2d4f4cb0bbb9d3d7407c 
Sep-03 06:56:48.197 [JavaFX Application Thread] INFO  b.c.d.g.p.ProposalService: We received a TempProposalPayload and store it to our protectedStoreList. proposalTxId=dd343de1ea38cddf0c1bd29c6f03a0ffe208c8b359cd1860acd0b8390c3bc598 

@chimp1984
Copy link
Contributor

chimp1984 commented Sep 2, 2019

There are other performance issues still. @christophsturm i strying to find a good profiler so we can see which methods are called too often and how much cpu time they consume. VisualVM is not good enough for that...

julianknutsen added a commit to julianknutsen/bisq that referenced this issue Nov 17, 2019
…ch removes

bisq-network#3143 identified an issue that tempProposals listeners were being
signaled once for each item that was removed during the P2PDataStore
operation that expired old TempProposal objects. Some of the listeners
are very expensive (ProposalListPresentation::updateLists()) which results
in large UI performance issues.

Now that the infrastructure is in place to receive updates from the
P2PDataStore in a batch, the ProposalService can apply all of the removes
received from the P2PDataStore at once. This results in only 1 onChanged()
callback for each listener.

The end result is that updateLists() is only called once and the performance
problems are reduced.

This removes the need for bisq-network#3148 and those interfaces will be removed in
the next patch.
julianknutsen added a commit to julianknutsen/bisq that referenced this issue Nov 18, 2019
…ch removes

bisq-network#3143 identified an issue that tempProposals listeners were being
signaled once for each item that was removed during the P2PDataStore
operation that expired old TempProposal objects. Some of the listeners
are very expensive (ProposalListPresentation::updateLists()) which results
in large UI performance issues.

Now that the infrastructure is in place to receive updates from the
P2PDataStore in a batch, the ProposalService can apply all of the removes
received from the P2PDataStore at once. This results in only 1 onChanged()
callback for each listener.

The end result is that updateLists() is only called once and the performance
problems are reduced.

This removes the need for bisq-network#3148 and those interfaces will be removed in
the next patch.
julianknutsen added a commit to julianknutsen/bisq that referenced this issue Nov 18, 2019
…ch removes

bisq-network#3143 identified an issue that tempProposals listeners were being
signaled once for each item that was removed during the P2PDataStore
operation that expired old TempProposal objects. Some of the listeners
are very expensive (ProposalListPresentation::updateLists()) which results
in large UI performance issues.

Now that the infrastructure is in place to receive updates from the
P2PDataStore in a batch, the ProposalService can apply all of the removes
received from the P2PDataStore at once. This results in only 1 onChanged()
callback for each listener.

The end result is that updateLists() is only called once and the performance
problems are reduced.

This removes the need for bisq-network#3148 and those interfaces will be removed in
the next patch.
julianknutsen added a commit to julianknutsen/bisq that referenced this issue Nov 19, 2019
…ch removes

bisq-network#3143 identified an issue that tempProposals listeners were being
signaled once for each item that was removed during the P2PDataStore
operation that expired old TempProposal objects. Some of the listeners
are very expensive (ProposalListPresentation::updateLists()) which results
in large UI performance issues.

Now that the infrastructure is in place to receive updates from the
P2PDataStore in a batch, the ProposalService can apply all of the removes
received from the P2PDataStore at once. This results in only 1 onChanged()
callback for each listener.

The end result is that updateLists() is only called once and the performance
problems are reduced.

This removes the need for bisq-network#3148 and those interfaces will be removed in
the next patch.
ripcurlx added a commit that referenced this issue Nov 26, 2019
* [PR COMMENTS] Make maxSequenceNumberBeforePurge final

Instead of using a subclass that overwrites a value, utilize Guice
to inject the real value of 10000 in the app and let the tests overwrite
it with their own.

* [TESTS] Clean up 'Analyze Code' warnings

Remove unused imports and clean up some access modifiers now that
the final test structure is complete

* [REFACTOR] HashMapListener::onAdded/onRemoved

Previously, this interface was called each time an item was changed. This
required listeners to understand performance implications of multiple
adds or removes in a short time span.

Instead, give each listener the ability to process a list of added or
removed entrys which can help them avoid performance issues.

This patch is just a refactor. Each listener is called once for each
ProtectedStorageEntry. Future patches will change this.

* [REFACTOR] removeFromMapAndDataStore can operate on Collections

Minor performance overhead for constructing MapEntry and Collections
of one element, but keeps the code cleaner and all removes can still
use the same logic to remove from map, delete from data store, signal
listeners, etc.

The MapEntry type is used instead of Pair since it will require less
operations when this is eventually used in the removeExpiredEntries path.

* Change removeFromMapAndDataStore to signal listeners at the end in a batch

All current users still call this one-at-a-time. But, it gives the ability
for the expire code path to remove in a batch.

* Update removeExpiredEntries to remove all items in a batch

This will cause HashMapChangedListeners to receive just one onRemoved()
call for the expire work instead of multiple onRemoved() calls for each
item.

This required a bit of updating for the remove validation in tests so
that it correctly compares onRemoved with multiple items.

* ProposalService::onProtectedDataRemoved signals listeners once on batch removes

#3143 identified an issue that tempProposals listeners were being
signaled once for each item that was removed during the P2PDataStore
operation that expired old TempProposal objects. Some of the listeners
are very expensive (ProposalListPresentation::updateLists()) which results
in large UI performance issues.

Now that the infrastructure is in place to receive updates from the
P2PDataStore in a batch, the ProposalService can apply all of the removes
received from the P2PDataStore at once. This results in only 1 onChanged()
callback for each listener.

The end result is that updateLists() is only called once and the performance
problems are reduced.

This removes the need for #3148 and those interfaces will be removed in
the next patch.

* Remove HashmapChangedListener::onBatch operations

Now that the only user of this interface has been removed, go ahead
and delete it. This is a partial revert of
f5d75c4 that includes the code that was
added into ProposalService that subscribed to the P2PDataStore.

* [TESTS] Regression test for #3629

Write a test that shows the incorrect behavior for #3629, the hashmap
is rebuilt from disk using the 20-byte key instead of the 32-byte key.

* [BUGFIX] Reconstruct HashMap using 32-byte key

Addresses the first half of #3629 by ensuring that the reconstructed
HashMap always has the 32-byte key for each payload.

It turns out, the TempProposalStore persists the ProtectedStorageEntrys
on-disk as a List and doesn't persist the key at all. Then, on
reconstruction, it creates the 20-byte key for its internal map.

The fix is to update the TempProposalStore to use the 32-byte key instead.
This means that all writes, reads, and reconstrution of the TempProposalStore
uses the 32-byte key which matches perfectly with the in-memory map
of the P2PDataStorage that expects 32-byte keys.

Important to note that until all seednodes receive this update, nodes
will continue to have both the 20-byte and 32-byte keys in their HashMap.

* [BUGFIX] Use 32-byte key in requestData path

Addresses the second half of #3629 by using the HashMap, not the
protectedDataStore to generate the known keys in the requestData path.

This won't have any bandwidth reduction until all seednodes have the
update and only have the 32-byte key in their HashMap.

fixes #3629

* [DEAD CODE] Remove getProtectedDataStoreMap

The only user has been migrated to getMap(). Delete it so future
development doesn't have the same 20-byte vs 32-byte key issue.

* [TESTS] Allow tests to validate SequenceNumberMap write separately

In order to implement remove-before-add behavior, we need a way to
verify that the SequenceNumberMap was the only item updated.

* Implement remove-before-add message sequence behavior

It is possible to receive a RemoveData or RemoveMailboxData message
before the relevant AddData, but the current code does not handle
it.

This results in internal state updates and signal handler's being called
when an Add is received with a lower sequence number than a previously
seen Remove.

Minor test validation changes to allow tests to specify that only the
SequenceNumberMap should be written during an operation.

* [TESTS] Allow remove() verification to be more flexible

Now that we have introduced remove-before-add, we need a way
to validate that the SequenceNumberMap was written, but nothing
else. Add this feature to the validation path.

* Broadcast remove-before-add messages to P2P network

In order to aid in propagation of remove() messages, broadcast them
in the event the remove is seen before the add.

* [TESTS] Clean up remove verification helpers

Now that there are cases where the SequenceNumberMap and Broadcast
are called, but no other internal state is updated, the existing helper
functions conflate too many decisions. Remove them in favor of explicitly
defining each state change expected.

* [BUGFIX] Fix duplicate sequence number use case (startup)

Fix a bug introduced in d484617 that
did not properly handle a valid use case for duplicate sequence numbers.

For in-memory-only ProtectedStoragePayloads, the client nodes need a way
to reconstruct the Payloads after startup from peer and seed nodes. This
involves sending a ProtectedStorageEntry with a sequence number that
is equal to the last one the client had already seen.

This patch adds tests to confirm the bug and fix as well as the changes
necessary to allow adding of Payloads that were previously seen, but
removed during a restart.

* Clean up AtomicBoolean usage in FileManager

Although the code was correct, it was hard to understand the relationship
between the to-be-written object and the savePending flag.

Trade two dependent atomics for one and comment the code to make it more
clear for the next reader.

* [DEADCODE] Clean up FileManager.java

* [BUGFIX] Shorter delay values not taking precedence

Fix a bug in the FileManager where a saveLater called with a low delay
won't execute until the delay specified by a previous saveLater call.

The trade off here is the execution of a task that returns early vs.
losing the requested delay.

* [REFACTOR] Inline saveNowInternal

Only one caller after deadcode removal.
ripcurlx added a commit that referenced this issue Nov 26, 2019
… PersistablePayload (#3640)

* [PR COMMENTS] Make maxSequenceNumberBeforePurge final

Instead of using a subclass that overwrites a value, utilize Guice
to inject the real value of 10000 in the app and let the tests overwrite
it with their own.

* [TESTS] Clean up 'Analyze Code' warnings

Remove unused imports and clean up some access modifiers now that
the final test structure is complete

* [REFACTOR] HashMapListener::onAdded/onRemoved

Previously, this interface was called each time an item was changed. This
required listeners to understand performance implications of multiple
adds or removes in a short time span.

Instead, give each listener the ability to process a list of added or
removed entrys which can help them avoid performance issues.

This patch is just a refactor. Each listener is called once for each
ProtectedStorageEntry. Future patches will change this.

* [REFACTOR] removeFromMapAndDataStore can operate on Collections

Minor performance overhead for constructing MapEntry and Collections
of one element, but keeps the code cleaner and all removes can still
use the same logic to remove from map, delete from data store, signal
listeners, etc.

The MapEntry type is used instead of Pair since it will require less
operations when this is eventually used in the removeExpiredEntries path.

* Change removeFromMapAndDataStore to signal listeners at the end in a batch

All current users still call this one-at-a-time. But, it gives the ability
for the expire code path to remove in a batch.

* Update removeExpiredEntries to remove all items in a batch

This will cause HashMapChangedListeners to receive just one onRemoved()
call for the expire work instead of multiple onRemoved() calls for each
item.

This required a bit of updating for the remove validation in tests so
that it correctly compares onRemoved with multiple items.

* ProposalService::onProtectedDataRemoved signals listeners once on batch removes

#3143 identified an issue that tempProposals listeners were being
signaled once for each item that was removed during the P2PDataStore
operation that expired old TempProposal objects. Some of the listeners
are very expensive (ProposalListPresentation::updateLists()) which results
in large UI performance issues.

Now that the infrastructure is in place to receive updates from the
P2PDataStore in a batch, the ProposalService can apply all of the removes
received from the P2PDataStore at once. This results in only 1 onChanged()
callback for each listener.

The end result is that updateLists() is only called once and the performance
problems are reduced.

This removes the need for #3148 and those interfaces will be removed in
the next patch.

* Remove HashmapChangedListener::onBatch operations

Now that the only user of this interface has been removed, go ahead
and delete it. This is a partial revert of
f5d75c4 that includes the code that was
added into ProposalService that subscribed to the P2PDataStore.

* [TESTS] Regression test for #3629

Write a test that shows the incorrect behavior for #3629, the hashmap
is rebuilt from disk using the 20-byte key instead of the 32-byte key.

* [BUGFIX] Reconstruct HashMap using 32-byte key

Addresses the first half of #3629 by ensuring that the reconstructed
HashMap always has the 32-byte key for each payload.

It turns out, the TempProposalStore persists the ProtectedStorageEntrys
on-disk as a List and doesn't persist the key at all. Then, on
reconstruction, it creates the 20-byte key for its internal map.

The fix is to update the TempProposalStore to use the 32-byte key instead.
This means that all writes, reads, and reconstrution of the TempProposalStore
uses the 32-byte key which matches perfectly with the in-memory map
of the P2PDataStorage that expects 32-byte keys.

Important to note that until all seednodes receive this update, nodes
will continue to have both the 20-byte and 32-byte keys in their HashMap.

* [BUGFIX] Use 32-byte key in requestData path

Addresses the second half of #3629 by using the HashMap, not the
protectedDataStore to generate the known keys in the requestData path.

This won't have any bandwidth reduction until all seednodes have the
update and only have the 32-byte key in their HashMap.

fixes #3629

* [DEAD CODE] Remove getProtectedDataStoreMap

The only user has been migrated to getMap(). Delete it so future
development doesn't have the same 20-byte vs 32-byte key issue.

* [TESTS] Allow tests to validate SequenceNumberMap write separately

In order to implement remove-before-add behavior, we need a way to
verify that the SequenceNumberMap was the only item updated.

* Implement remove-before-add message sequence behavior

It is possible to receive a RemoveData or RemoveMailboxData message
before the relevant AddData, but the current code does not handle
it.

This results in internal state updates and signal handler's being called
when an Add is received with a lower sequence number than a previously
seen Remove.

Minor test validation changes to allow tests to specify that only the
SequenceNumberMap should be written during an operation.

* [TESTS] Allow remove() verification to be more flexible

Now that we have introduced remove-before-add, we need a way
to validate that the SequenceNumberMap was written, but nothing
else. Add this feature to the validation path.

* Broadcast remove-before-add messages to P2P network

In order to aid in propagation of remove() messages, broadcast them
in the event the remove is seen before the add.

* [TESTS] Clean up remove verification helpers

Now that there are cases where the SequenceNumberMap and Broadcast
are called, but no other internal state is updated, the existing helper
functions conflate too many decisions. Remove them in favor of explicitly
defining each state change expected.

* [BUGFIX] Fix duplicate sequence number use case (startup)

Fix a bug introduced in d484617 that
did not properly handle a valid use case for duplicate sequence numbers.

For in-memory-only ProtectedStoragePayloads, the client nodes need a way
to reconstruct the Payloads after startup from peer and seed nodes. This
involves sending a ProtectedStorageEntry with a sequence number that
is equal to the last one the client had already seen.

This patch adds tests to confirm the bug and fix as well as the changes
necessary to allow adding of Payloads that were previously seen, but
removed during a restart.

* Clean up AtomicBoolean usage in FileManager

Although the code was correct, it was hard to understand the relationship
between the to-be-written object and the savePending flag.

Trade two dependent atomics for one and comment the code to make it more
clear for the next reader.

* [DEADCODE] Clean up FileManager.java

* [BUGFIX] Shorter delay values not taking precedence

Fix a bug in the FileManager where a saveLater called with a low delay
won't execute until the delay specified by a previous saveLater call.

The trade off here is the execution of a task that returns early vs.
losing the requested delay.

* [REFACTOR] Inline saveNowInternal

Only one caller after deadcode removal.

* [TESTS] Introduce MapStoreServiceFake

Now that we want to make changes to the MapStoreService,
it isn't sufficient to have a Fake of the ProtectedDataStoreService.

Tests now use a REAL ProtectedDataStoreService and a FAKE MapStoreService
to exercise more of the production code and allow future testing of
changes to MapStoreService.

* Persist changes to ProtectedStorageEntrys

With the addition of ProtectedStorageEntrys, there are now persistable
maps that have different payloads and the same keys. In the
ProtectedDataStoreService case, the value is the ProtectedStorageEntry
which has a createdTimeStamp, sequenceNumber, and signature that can
all change, but still contain an identical payload.

Previously, the service was only updating the on-disk representation on
the first object and never again. So, when it was recreated from disk it
would not have any of the updated metadata. This was just copied from the
append-only implementation where the value was the Payload
which was immutable.

This hasn't caused any issues to this point, but it causes strange behavior
such as always receiving seqNr==1 items from seednodes on startup. It
is good practice to keep the in-memory objects and on-disk objects in
sync and removes an unexpected failure in future dev work that expects
the same behavior as the append-only on-disk objects.

* [DEADCODE] Remove protectedDataStoreListener

There were no users.

* [DEADCODE] Remove unused methods in ProtectedDataStoreService
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

No branches or pull requests

5 participants