Commit 3e4a25d
authored
fix(test): fix flakiness of TestPersistLFDiscardStats (#1963)
fixes DGRAPHCORE-234
## Problem
The purpose of TestPersistLFDiscardStats is to make sure that if you
make changes to the file such that we need to maintain the discardStats
in the value log, and if you close the DB, then when you reopen the DB,
you remember the same status.
Note that the DiscardStats are updated when we perform compaction, and
in our test cases we have 4 compactors concurrently running
(with ids 0, 1, 2, and 3). Most of the time, we were fine when we captured
a single compaction cycle -- and then closed the DB and then reopened.
However, there was a race condition wherein we waited for some arbitrary
amount of time, then captured the current discardStats, then closed the
DB. The problem is that between the time that we capture the discardStatus
and close the DB, another compaction cycle may have started!
Hence, every once in a while, we would find that the saved copy of the discard
stats would not match what we picked up later when we reopened the file.
## Solution
As noted in the problem statement, we ended up waiting an "arbitrary amount
of time" instead of waiting for specific events and then reacting to those events.
Specifically, we wanted to wait until at least "some stats" had been generated,
and then we waited for compaction to complete. Unfortunately, there did not
exist a clear way (previously) to capture the event of "some stats having been
generated", nor was there a way to capture the discardStats upon closure of
the database.
The solution then was to add in two things: first, a test channel in the database
where we can log messages to this channel, but only when the channel has
been specified. Second, we add in a means (via options.go) of specifying
an "onCloseDiscardCapture" map. This map will be populated (assuming it
was initialized and is not nil) when we close the db and specifically when we
close the valueLog.
We no longer rely on time.Sleep, but instead rely on specific events.1 parent 907dd65 commit 3e4a25d
File tree
6 files changed
+139
-8
lines changed6 files changed
+139
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| |||
252 | 254 | | |
253 | 255 | | |
254 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
255 | 260 | | |
256 | 261 | | |
257 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
43 | 79 | | |
44 | 80 | | |
45 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
| 557 | + | |
| 558 | + | |
557 | 559 | | |
558 | 560 | | |
559 | 561 | | |
| |||
640 | 642 | | |
641 | 643 | | |
642 | 644 | | |
| 645 | + | |
643 | 646 | | |
644 | 647 | | |
645 | 648 | | |
| |||
1103 | 1106 | | |
1104 | 1107 | | |
1105 | 1108 | | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
1106 | 1112 | | |
1107 | 1113 | | |
1108 | 1114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
496 | 495 | | |
497 | 496 | | |
498 | 497 | | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
499 | 501 | | |
500 | 502 | | |
501 | 503 | | |
| 504 | + | |
| 505 | + | |
502 | 506 | | |
503 | 507 | | |
504 | 508 | | |
| |||
522 | 526 | | |
523 | 527 | | |
524 | 528 | | |
525 | | - | |
| 529 | + | |
| 530 | + | |
526 | 531 | | |
527 | | - | |
528 | 532 | | |
529 | 533 | | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | 534 | | |
534 | 535 | | |
535 | 536 | | |
| |||
539 | 540 | | |
540 | 541 | | |
541 | 542 | | |
542 | | - | |
| 543 | + | |
543 | 544 | | |
544 | 545 | | |
545 | 546 | | |
546 | 547 | | |
547 | 548 | | |
548 | | - | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
549 | 552 | | |
550 | 553 | | |
551 | 554 | | |
| |||
0 commit comments