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

Bug fix panic tps benchmark #2279

Merged
merged 4 commits into from
Sep 8, 2020
Merged

Conversation

miiu96
Copy link
Contributor

@miiu96 miiu96 commented Sep 8, 2020

Fix concurrent access on map that store shard statistics information for TPS Benchmark.
When method ShardStatistics() is called will return a copy of map that contains shard statistics.

@miiu96 miiu96 self-assigned this Sep 8, 2020
andreibancioiu
andreibancioiu previously approved these changes Sep 8, 2020
@@ -179,8 +179,13 @@ func (s *TpsBenchmark) NrOfShards() uint32 {
// ShardStatistics returns the current statistical state for a given shard
func (s *TpsBenchmark) ShardStatistics() map[uint32]ShardStatistic {
s.mut.RLock()
defer s.mut.RUnlock()
return s.shardStatistics
copyMapShardStatistics := make(map[uint32]ShardStatistic)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems fine, I see that updateStatistics is protected by the same lock.

Copy link
Contributor

Choose a reason for hiding this comment

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

rename to shardStatisticsMapCopy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@@ -179,8 +179,13 @@ func (s *TpsBenchmark) NrOfShards() uint32 {
// ShardStatistics returns the current statistical state for a given shard
func (s *TpsBenchmark) ShardStatistics() map[uint32]ShardStatistic {
s.mut.RLock()
defer s.mut.RUnlock()
return s.shardStatistics
copyMapShardStatistics := make(map[uint32]ShardStatistic)
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to shardStatisticsMapCopy

func TestTpsBenchmark_ShardStatisticConcurrentAccess(t *testing.T) {
t.Parallel()

tpsBenchmark, _ := statistics.NewTPSBenchmark(12, 4)
Copy link
Contributor

Choose a reason for hiding this comment

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

use recover() as you should check that no panic has encountered during the test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Contributor

@LucianMincu LucianMincu left a comment

Choose a reason for hiding this comment

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

System tests passed

@LucianMincu LucianMincu merged commit 4938ffa into development Sep 8, 2020
@LucianMincu LucianMincu deleted the bug-fix-panic-tps-benchmark branch September 8, 2020 16:51
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.

None yet

4 participants