Repository navigation
Extend radix_tree tests and disable operator-- (for MtMode) - #1156
Conversation
igchor
left a comment
There was a problem hiding this comment.
Reviewed 7 of 9 files at r1.
Reviewable status: 7 of 9 files reviewed, 2 unresolved discussions (waiting on @lukaszstolarczuk)
include/libpmemobj++/experimental/radix_tree.hpp, line 3155 at r1 (raw file):
/* * If MtMode == true it's not safe to use this operator (iterator may end up * invalid if concurrent erase happen).
Actually, the operator++ should work just fine, there's a problem only with operator--.
tests/radix_tree/radix_concurrent_erase.cpp, line 161 at r1 (raw file):
// i, // value_repeats)); // ++it;
The assertion fires here beacuse you are going out of bounds (call ++it on iterator which is already end()). This loops iterates for INITIAL_ELEMENTS times, but the actual number of element in the tree can be less due to the concurrent erases. If you fix this, this test should pass I belive.
5c2d762 to
efff763
Compare
efff763 to
fc9d5d9
Compare
lukaszstolarczuk
left a comment
There was a problem hiding this comment.
Reviewable status: 4 of 9 files reviewed, 2 unresolved discussions (waiting on @igchor)
include/libpmemobj++/experimental/radix_tree.hpp, line 3155 at r1 (raw file):
Previously, igchor (Igor Chorążewicz) wrote…
Actually, the operator++ should work just fine, there's a problem only with operator--.
Done.
tests/radix_tree/radix_concurrent_erase.cpp, line 161 at r1 (raw file):
Previously, igchor (Igor Chorążewicz) wrote…
The assertion fires here beacuse you are going out of bounds (call ++it on iterator which is already end()). This loops iterates for INITIAL_ELEMENTS times, but the actual number of element in the tree can be less due to the concurrent erases. If you fix this, this test should pass I belive.
Done.
Codecov Report
@@ Coverage Diff @@
## master #1156 +/- ##
==========================================
+ Coverage 94.05% 94.08% +0.02%
==========================================
Files 52 52
Lines 5163 5154 -9
==========================================
- Hits 4856 4849 -7
+ Misses 307 305 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
igchor
left a comment
There was a problem hiding this comment.
Reviewable status: 4 of 9 files reviewed, 2 unresolved discussions (waiting on @igchor and @lukaszstolarczuk)
tests/radix_tree/radix_concurrent_erase.cpp, line 104 at r3 (raw file):
// i, // value_repeats)); // --it;
I think that this test has the same problem as the one for operator++ (that is, if we fix operator--, this test will still fail).
fc9d5d9 to
096a8b1
Compare
lukaszstolarczuk
left a comment
There was a problem hiding this comment.
Reviewable status: 0 of 9 files reviewed, 2 unresolved discussions (waiting on @igchor)
tests/radix_tree/radix_concurrent_erase.cpp, line 104 at r3 (raw file):
Previously, igchor (Igor Chorążewicz) wrote…
I think that this test has the same problem as the one for operator++ (that is, if we fix operator--, this test will still fail).
right now it.. works - I run this in the loop and it didn't fail... so I guess, something is wrong...?
igchor
left a comment
There was a problem hiding this comment.
Reviewable status: 0 of 9 files reviewed, 2 unresolved discussions (waiting on @igchor and @lukaszstolarczuk)
tests/radix_tree/radix_concurrent_erase.cpp, line 104 at r3 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
right now it.. works - I run this in the loop and it didn't fail... so I guess, something is wrong...?
Well, operator-- will fail only in some specific cases, e.g.:
- try_decrement fails due to concurrent erase (it can be the element pointed to by the iterator)
- operator-- calls lower_boud which returns end() (the tree is now empty)
- try_decrement crashes because we decerement beyond begin()
So, one idea for a test would be to just have a single element in the tree and in one thread call find() and then operator--, in another thread, just remove this element. Probably this should be done in a loop.
096a8b1 to
765af38
Compare
765af38 to
c12c1d4
Compare
lukaszstolarczuk
left a comment
There was a problem hiding this comment.
Reviewable status: 0 of 9 files reviewed, 1 unresolved discussion (waiting on @igchor)
tests/radix_tree/radix_concurrent_erase.cpp, line 104 at r3 (raw file):
Previously, igchor (Igor Chorążewicz) wrote…
Well, operator-- will fail only in some specific cases, e.g.:
- try_decrement fails due to concurrent erase (it can be the element pointed to by the iterator)
- operator-- calls lower_boud which returns end() (the tree is now empty)
- try_decrement crashes because we decerement beyond begin()
So, one idea for a test would be to just have a single element in the tree and in one thread call find() and then operator--, in another thread, just remove this element. Probably this should be done in a loop.
I've done it a bit differently with random removals - now it fails randomly
igchor
left a comment
There was a problem hiding this comment.
Reviewed 3 of 9 files at r5.
Reviewable status: 3 of 9 files reviewed, all discussions resolved (waiting on @igchor)
c12c1d4 to
27fb370
Compare
lukaszstolarczuk
left a comment
There was a problem hiding this comment.
as discussed I switched implementation, to disable operator-- when MtMode is enabled
Reviewable status: 3 of 9 files reviewed, all discussions resolved (waiting on @igchor)
igchor
left a comment
There was a problem hiding this comment.
Reviewable status: 3 of 9 files reviewed, all discussions resolved (waiting on @igchor)
657cea4 to
da898f7
Compare
Concurrency issue may occur if an element is removed during decrement.
the usings' names were a bit to elaborate and they influence line limit.
da898f7 to
75d04ac
Compare
lukaszstolarczuk
left a comment
There was a problem hiding this comment.
Reviewable status: 3 of 9 files reviewed, 1 unresolved discussion (waiting on @igchor)
tests/radix_tree/radix_concurrent_iterate.cpp, line 249 at r8 (raw file):
middle_key.end()); auto last = std::next(ptr->begin(), static_cast<int>(ptr->size() - 1));
I'm not sure if this is exactly what we wanted here? Will the find & erase (below) do the job as we wanted?
igchor
left a comment
There was a problem hiding this comment.
Reviewable status: 3 of 9 files reviewed, 1 unresolved discussion (waiting on @igchor and @lukaszstolarczuk)
tests/radix_tree/radix_concurrent_iterate.cpp, line 249 at r8 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
I'm not sure if this is exactly what we wanted here? Will the find & erase (below) do the job as we wanted?
Yes, I think it's the same.
operator--whenMtModeis enabledrandom fails in
try_decrement()This change is