Repository navigation
Commit e33e048
authored
[fix](be) Stop two SNII unit tests from trampling shared state (apache#66961)
### What problem does this PR solve?
Issue Number: N/A
Related PR: N/A
Problem Summary:
Two cases under `be/test/storage/index/snii/` reach outside their own
test and
break unrelated cases. Both are test-only; no production code changes.
**1. A fixed `/tmp` scratch path (`metered_file_reader_test.cpp`)**
`MakeRampFile()` built its 256-byte ramp file at the constant path
`/tmp/snii_metered_ramp.bin`. On a shared build machine that file
belongs to
whoever ran the suite first; every later user gets `EACCES` from
`::open`, and
all seven `SniiMeteredFileReader` cases fail at the first assertion with
no hint
that a foreign file is the cause:
```
metered_file_reader_test.cpp:42: Failure
Value of: w.open(path).ok() Actual: false Expected: true
```
Every other scratch path in this subtree already namespaces itself with
the pid
and a counter, and the nearest neighbour in the same directory
(`file_reader_caller_buffer_test.cpp`) also `std::remove()`s the file
afterwards.
This PR adopts both halves of that convention: the ramp file becomes a
`RampFile`
RAII object whose name carries the pid and a counter and whose
destructor removes
it. Removing matters as much as naming — a leftover file is what causes
the
collision in the first place, and pids get recycled.
**2. A permanently lowered `RLIMIT_NOFILE`
(`spimi_term_buffer_test.cpp`)**
`SniiSpimiTermBuffer.SpillOpenIoFailureLatched` drives a spill's
`::open` to
`EMFILE` by lowering `RLIMIT_NOFILE` to a hardcoded 64 and then opening
`/dev/null` until the table is full. Two things go wrong once the binary
already
holds more than 64 descriptors:
1. The cap assumes the process holds fewer than 64 descriptors, so the
hog loop
can still take one. Sampling `/proc/<pid>/fd` during a run shows the
SNII cases
alone keep the process at **14** descriptors, but adding the CLucene
inverted
index cases to the same binary takes it to **273** — they hold hundreds
of
index files open at once. Above the cap the very first `::open` already
fails,
`hogs` stays empty, and the case stops at `ASSERT_FALSE(hogs.empty())`.
What
decides this is *which* cases share the binary, not how many.
2. That assertion is fatal, so it returns from the test body — and the
code that
restores `RLIMIT_NOFILE` sits after it and never runs. The whole process
stays
capped at 64 descriptors for every later case.
The result is not a descriptor leak but a cascade: the next four
`SniiSpimiTermBuffer` cases fail instantly because they cannot open a
spill file,
and the first death test after them aborts the entire run when gtest's
`pipe()`
hits `EMFILE`:
```
CHECK failed: gtest-death-test.cc, line 1400: pipe(pipe_fd) != -1
Aborted
```
The fix holds the tight limit and the hog descriptors in an inner scope
whose
`Defer` restores `RLIMIT_NOFILE` and closes the descriptors on every
exit path,
fatal assertion included; and derives the cap from
`::dup(STDIN_FILENO)`, the
lowest free descriptor, instead of a fixed 64, so the case no longer
depends on
which tests ran before it. The case still drives the spill open to
`EMFILE` and
still asserts the error is latched.
**Before / after**, with
`--filter='*Snii*:*snii*:*SNII*:CollectionStatisticsTest.*:*InvertedIndex*:*inverted_index*'`:
| | before | after |
|---|---|---|
| `SniiMeteredFileReader` | 7 failed | pass |
| `SniiSpimiTermBuffer*` | 5 failed | pass |
| death test | aborted the run | pass |
| total | run truncated by the abort | 1693 passed, 0 failed |1 parent 02fbf37 commit e33e048
2 files changed
Lines changed: 77 additions & 42 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
46 | 58 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
51 | 66 | | |
52 | 67 | | |
53 | 68 | | |
54 | 69 | | |
55 | 70 | | |
56 | 71 | | |
| 72 | + | |
57 | 73 | | |
58 | | - | |
| 74 | + | |
59 | 75 | | |
60 | 76 | | |
61 | 77 | | |
| |||
84 | 100 | | |
85 | 101 | | |
86 | 102 | | |
| 103 | + | |
87 | 104 | | |
88 | | - | |
| 105 | + | |
89 | 106 | | |
90 | 107 | | |
91 | 108 | | |
| |||
98 | 115 | | |
99 | 116 | | |
100 | 117 | | |
| 118 | + | |
101 | 119 | | |
102 | | - | |
| 120 | + | |
103 | 121 | | |
104 | 122 | | |
105 | 123 | | |
| |||
117 | 135 | | |
118 | 136 | | |
119 | 137 | | |
| 138 | + | |
120 | 139 | | |
121 | | - | |
| 140 | + | |
122 | 141 | | |
123 | 142 | | |
124 | 143 | | |
| |||
134 | 153 | | |
135 | 154 | | |
136 | 155 | | |
| 156 | + | |
137 | 157 | | |
138 | | - | |
| 158 | + | |
139 | 159 | | |
140 | 160 | | |
141 | 161 | | |
| |||
150 | 170 | | |
151 | 171 | | |
152 | 172 | | |
| 173 | + | |
153 | 174 | | |
154 | | - | |
| 175 | + | |
155 | 176 | | |
156 | 177 | | |
157 | 178 | | |
| |||
165 | 186 | | |
166 | 187 | | |
167 | 188 | | |
| 189 | + | |
168 | 190 | | |
169 | | - | |
| 191 | + | |
170 | 192 | | |
171 | 193 | | |
172 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
514 | 515 | | |
515 | 516 | | |
516 | 517 | | |
517 | | - | |
518 | 518 | | |
519 | 519 | | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
536 | 531 | | |
537 | | - | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
538 | 553 | | |
539 | | - | |
540 | | - | |
541 | | - | |
| 554 | + | |
542 | 555 | | |
543 | | - | |
544 | | - | |
| 556 | + | |
| 557 | + | |
545 | 558 | | |
546 | 559 | | |
547 | 560 | | |
| |||
0 commit comments