Commit 8a225a4
committed
Fix protobuf temp directory leak in ProtoBufUtils
ProtoBufUtils.getFileCopiedToLocal() created temporary directories
with prefix "pinot-protobuf" that were never cleaned up. Every call
to ProtoBufMessageDecoder.init(), ProtoBufRecordReader.init(), or
ProtoBufCodeGenMessageDecoder.init() leaked one directory under
java.io.tmpdir.
For descriptor file callers (ProtoBufMessageDecoder, ProtoBufRecordReader):
replace the copy-to-temp-then-open pattern with readDescriptorFileBytes()
which streams bytes directly via PinotFS.open() - no temp files at all.
For the JAR caller (ProtoBufCodeGenMessageDecoder): resolve the JAR
to a local File inline. Local JARs are used directly without copying.
Remote JARs are copied to a temp directory that intentionally persists
for the decoder's lifetime because the JVM may lazily resolve classes
from the JAR at decode time via the URLClassLoader chain. Since
StreamMessageDecoder does not extend Closeable, there is no lifecycle
hook to clean up, but this is a one-time-per-consumer-init cost and
consumers are long-lived.
Removed dead methods: getFileCopiedToLocal(), getDescriptorFileInputStream(),
createLocalFile(), withLocalFile(), and FileAction from ProtoBufUtils.
Renamed loadClass(File) to createClassLoader(File) for clarity.
Testing:
- Added ProtoBufTempFileLeakTest with 5 tests covering all three code
paths. Each test snapshots pinot-protobuf* directories in java.io.tmpdir
before the operation, performs the operation with functional correctness
assertions (decoding a message and checking field values), then asserts
no new temp directories remain afterward.
- testMessageDecoderInitDoesNotLeakTempDir: simple descriptor via
ProtoBufMessageDecoder, verifies decode of sample record fields.
- testMessageDecoderComplexDescriptorDoesNotLeakTempDir: complex
nested descriptor via ProtoBufMessageDecoder.
- testCodeGenDecoderInitDoesNotLeakTempDir: simple JAR via
ProtoBufCodeGenMessageDecoder, verifies decode after init cleanup.
- testCodeGenDecoderComplexJarDoesNotLeakTempDir: complex JAR with
nested/repeated/map types via ProtoBufCodeGenMessageDecoder.
- testRecordReaderLifecycleDoesNotLeakTempDir: full ProtoBufRecordReader
lifecycle (init, read, close) with delimited protobuf data file.
- All 5 tests confirmed to fail before the fix (each leaking 1 temp
directory) and pass after. Full module suite: 172/172 tests pass.1 parent 5e914c9 commit 8a225a4
6 files changed
Lines changed: 273 additions & 48 deletions
File tree
- pinot-plugins/pinot-input-format/pinot-protobuf/src
- main/java/org/apache/pinot/plugin/inputformat/protobuf
- test/java/org/apache/pinot/plugin/inputformat/protobuf
Lines changed: 44 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| 37 | + | |
| 38 | + | |
34 | 39 | | |
35 | 40 | | |
| 41 | + | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
38 | 50 | | |
| 51 | + | |
| 52 | + | |
39 | 53 | | |
40 | 54 | | |
41 | 55 | | |
| |||
49 | 63 | | |
50 | 64 | | |
51 | 65 | | |
52 | | - | |
| 66 | + | |
| 67 | + | |
53 | 68 | | |
54 | 69 | | |
55 | 70 | | |
56 | 71 | | |
57 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
58 | 78 | | |
59 | 79 | | |
60 | 80 | | |
| |||
75 | 95 | | |
76 | 96 | | |
77 | 97 | | |
78 | | - | |
| 98 | + | |
79 | 99 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 100 | + | |
| 101 | + | |
84 | 102 | | |
85 | 103 | | |
86 | 104 | | |
| |||
104 | 122 | | |
105 | 123 | | |
106 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
107 | 145 | | |
Lines changed: 4 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
| |||
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
51 | | - | |
52 | | - | |
53 | | - | |
| 50 | + | |
| 51 | + | |
54 | 52 | | |
55 | 53 | | |
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
59 | 57 | | |
60 | | - | |
| 58 | + | |
61 | 59 | | |
62 | 60 | | |
63 | | - | |
| 61 | + | |
64 | 62 | | |
65 | 63 | | |
66 | 64 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
Lines changed: 10 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | 23 | | |
26 | 24 | | |
27 | | - | |
28 | | - | |
29 | 25 | | |
30 | 26 | | |
31 | | - | |
32 | | - | |
33 | 27 | | |
34 | 28 | | |
35 | | - | |
36 | 29 | | |
37 | 30 | | |
38 | 31 | | |
39 | 32 | | |
40 | 33 | | |
41 | 34 | | |
42 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
43 | 41 | | |
44 | | - | |
| 42 | + | |
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
48 | 46 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
60 | 50 | | |
61 | 51 | | |
62 | 52 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | 53 | | |
77 | 54 | | |
78 | 55 | | |
| |||
0 commit comments