fix: multithreading issue part 2#512
Conversation
…h in delegate queue
| - (void)updateAttributesFromSimplifiedMasternodeEntry:(DSSimplifiedMasternodeEntry *)simplifiedMasternodeEntry atBlockHeight:(uint32_t)blockHeight knownOperatorAddresses:(NSDictionary<NSString *, DSAddressEntity *> *)knownOperatorAddresses knownVotingAddresses:(NSDictionary<NSString *, DSAddressEntity *> *)knownVotingAddresses localMasternodes:(NSDictionary<NSData *, DSLocalMasternodeEntity *> *)localMasternodes { | ||
| if (self.updateHeight < blockHeight) { | ||
| NSAssert(simplifiedMasternodeEntry.updateHeight == blockHeight, @"the block height should be the same as the entry update height"); | ||
| //NSAssert(simplifiedMasternodeEntry.updateHeight == blockHeight, @"the block height should be the same as the entry update height"); |
tikhop
left a comment
There was a problem hiding this comment.
Most of the PR looks good except the overuse of '@synchronized'. I don't think this is the solution to our multithreading issues.
| double maxAmount = self.masternodeListRetrievalQueueMaxAmount; | ||
| if (!amountLeft) { | ||
| return self.store.masternodeListsAndQuorumsIsSynced; | ||
| @synchronized (self) { |
There was a problem hiding this comment.
@pankcuf I don't think @synchronized is a real solution, I personally against using @synchronized because it can lead performance decreasing and other "unknowns"
| return 1; | ||
| } else { | ||
| return 0; | ||
| @synchronized (self.peerManager) { |
There was a problem hiding this comment.
@pankcuf I don't think @synchronized is a real solution, I personally against using @synchronized because it can lead performance decreasing and other "unknowns"
| self.store.lastQueriedBlockHash = blockHash; | ||
| NSData *blockHashData = uint256_data(blockHash); | ||
| [self.store.masternodeListQueriesNeedingQuorumsValidated addObject:blockHashData]; | ||
| @synchronized (self.store.masternodeListQueriesNeedingQuorumsValidated) { |
There was a problem hiding this comment.
@pankcuf I don't think @synchronized is a real solution, I personally against using @synchronized because it can lead performance decreasing and other "unknowns"
| NSData *masternodeListBlockHashData = uint256_data(masternodeListBlockHash); | ||
| if ([neededMissingMasternodeLists count] && [self.store.masternodeListQueriesNeedingQuorumsValidated containsObject:masternodeListBlockHashData]) { | ||
| BOOL hasAwaitingQuorumValidation; | ||
| @synchronized (self.store.masternodeListQueriesNeedingQuorumsValidated) { |
There was a problem hiding this comment.
@pankcuf I don't think @synchronized is a real solution, I personally against using @synchronized because it can lead performance decreasing and other "unknowns"
| if (uint256_eq(self.store.lastQueriedBlockHash, masternodeListBlockHash)) { | ||
| self.masternodeListDiffService.currentMasternodeList = masternodeList; | ||
| [self.store.masternodeListQueriesNeedingQuorumsValidated removeObject:masternodeListBlockHashData]; | ||
| @synchronized (self.store.masternodeListQueriesNeedingQuorumsValidated) { |
There was a problem hiding this comment.
@pankcuf I don't think @synchronized is a real solution, I personally against using @synchronized because it can lead performance decreasing and other "unknowns"
|
In addition all tests are failing and it will be good to have them working again |
|
Another minor issue is PR's title. We agreed a year ago to use conventional style. |
|
@tikhop You claim that the use "@synchronized" leads to some kind of overhead. In general I agree with that point. But from my perspective, we must proceed from practical considerations and we have several alternatives:
Therefore, I suggest as follows, roll out the build from this feature branch and test it. If it's ok, then to merge it. |
Issue being fixed or feature implemented
Fix: some thread-safety issues
Add disconnect reason entity
What was done?
How Has This Been Tested?
Breaking Changes
Checklist:
For repository code-owners and collaborators only