Commit 375fd15
Refactor indexer (#25174)
Refactor `modules/indexer` to make it more maintainable. And it can be
easier to support more features. I'm trying to solve some of issue
searching, this is a precursor to making functional changes.
Current supported engines and the index versions:
| engines | issues | code |
| - | - | - |
| db | Just a wrapper for database queries, doesn't need version | - |
| bleve | The version of index is **2** | The version of index is **6**
|
| elasticsearch | The old index has no version, will be treated as
version **0** in this PR | The version of index is **1** |
| meilisearch | The old index has no version, will be treated as version
**0** in this PR | - |
## Changes
### Split
Splited it into mutiple packages
```text
indexer
├── internal
│ ├── bleve
│ ├── db
│ ├── elasticsearch
│ └── meilisearch
├── code
│ ├── bleve
│ ├── elasticsearch
│ └── internal
└── issues
├── bleve
├── db
├── elasticsearch
├── internal
└── meilisearch
```
- `indexer/interanal`: Internal shared package for indexer.
- `indexer/interanal/[engine]`: Internal shared package for each engine
(bleve/db/elasticsearch/meilisearch).
- `indexer/code`: Implementations for code indexer.
- `indexer/code/internal`: Internal shared package for code indexer.
- `indexer/code/[engine]`: Implementation via each engine for code
indexer.
- `indexer/issues`: Implementations for issues indexer.
### Deduplication
- Combine `Init/Ping/Close` for code indexer and issues indexer.
- ~Combine `issues.indexerHolder` and `code.wrappedIndexer` to
`internal.IndexHolder`.~ Remove it, use dummy indexer instead when the
indexer is not ready.
- Duplicate two copies of creating ES clients.
- Duplicate two copies of `indexerID()`.
### Enhancement
- [x] Support index version for elasticsearch issues indexer, the old
index without version will be treated as version 0.
- [x] Fix spell of `elastic_search/ElasticSearch`, it should be
`Elasticsearch`.
- [x] Improve versioning of ES index. We don't need `Aliases`:
- Gitea does't need aliases for "Zero Downtime" because it never delete
old indexes.
- The old code of issues indexer uses the orignal name to create issue
index, so it's tricky to convert it to an alias.
- [x] Support index version for meilisearch issues indexer, the old
index without version will be treated as version 0.
- [x] Do "ping" only when `Ping` has been called, don't ping
periodically and cache the status.
- [x] Support the context parameter whenever possible.
- [x] Fix outdated example config.
- [x] Give up the requeue logic of issues indexer: When indexing fails,
call Ping to check if it was caused by the engine being unavailable, and
only requeue the task if the engine is unavailable.
- It is fragile and tricky, could cause data losing (It did happen when
I was doing some tests for this PR). And it works for ES only.
- Just always requeue the failed task, if it caused by bad data, it's a
bug of Gitea which should be fixed.
---------
Co-authored-by: Giteabot <teabot@gitea.io>1 parent b0215c4 commit 375fd15
File tree
43 files changed
+1373
-1425
lines changed- custom/conf
- docs/content/doc/administration
- modules
- context
- indexer
- code
- bleve
- elasticsearch
- internal
- internal
- bleve
- db
- elasticsearch
- meilisearch
- issues
- bleve
- db
- elasticsearch
- internal
- meilisearch
- stats
- routers/web
- explore
- repo
- user
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
43 files changed
+1373
-1425
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1334 | 1334 | | |
1335 | 1335 | | |
1336 | 1336 | | |
1337 | | - | |
1338 | | - | |
| 1337 | + | |
| 1338 | + | |
1339 | 1339 | | |
1340 | | - | |
| 1340 | + | |
1341 | 1341 | | |
1342 | 1342 | | |
1343 | 1343 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
461 | | - | |
462 | | - | |
| 461 | + | |
| 462 | + | |
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
| 469 | + | |
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
596 | | - | |
| 596 | + | |
597 | 597 | | |
598 | 598 | | |
599 | 599 | | |
| |||
Lines changed: 36 additions & 120 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | 34 | | |
36 | 35 | | |
37 | | - | |
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
| |||
59 | 57 | | |
60 | 58 | | |
61 | 59 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | 60 | | |
95 | 61 | | |
96 | 62 | | |
| |||
111 | 77 | | |
112 | 78 | | |
113 | 79 | | |
114 | | - | |
115 | | - | |
| 80 | + | |
| 81 | + | |
116 | 82 | | |
117 | 83 | | |
118 | 84 | | |
| |||
147 | 113 | | |
148 | 114 | | |
149 | 115 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 116 | + | |
161 | 117 | | |
162 | 118 | | |
163 | | - | |
| 119 | + | |
164 | 120 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
169 | 125 | | |
170 | 126 | | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
175 | 133 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | 134 | | |
183 | 135 | | |
184 | | - | |
185 | | - | |
| 136 | + | |
| 137 | + | |
186 | 138 | | |
187 | 139 | | |
188 | 140 | | |
| |||
227 | 179 | | |
228 | 180 | | |
229 | 181 | | |
230 | | - | |
| 182 | + | |
231 | 183 | | |
232 | 184 | | |
233 | 185 | | |
| |||
237 | 189 | | |
238 | 190 | | |
239 | 191 | | |
240 | | - | |
241 | | - | |
| 192 | + | |
| 193 | + | |
242 | 194 | | |
243 | 195 | | |
244 | 196 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | 197 | | |
282 | | - | |
283 | | - | |
| 198 | + | |
| 199 | + | |
284 | 200 | | |
285 | 201 | | |
286 | 202 | | |
| |||
308 | 224 | | |
309 | 225 | | |
310 | 226 | | |
311 | | - | |
| 227 | + | |
312 | 228 | | |
313 | 229 | | |
314 | | - | |
| 230 | + | |
315 | 231 | | |
316 | 232 | | |
317 | 233 | | |
318 | | - | |
| 234 | + | |
319 | 235 | | |
320 | 236 | | |
321 | 237 | | |
| |||
326 | 242 | | |
327 | 243 | | |
328 | 244 | | |
329 | | - | |
| 245 | + | |
330 | 246 | | |
331 | 247 | | |
332 | 248 | | |
| |||
379 | 295 | | |
380 | 296 | | |
381 | 297 | | |
382 | | - | |
| 298 | + | |
383 | 299 | | |
384 | 300 | | |
385 | 301 | | |
386 | 302 | | |
387 | 303 | | |
388 | 304 | | |
389 | | - | |
| 305 | + | |
390 | 306 | | |
391 | 307 | | |
392 | 308 | | |
| |||
405 | 321 | | |
406 | 322 | | |
407 | 323 | | |
408 | | - | |
| 324 | + | |
409 | 325 | | |
410 | 326 | | |
411 | 327 | | |
412 | | - | |
| 328 | + | |
413 | 329 | | |
414 | 330 | | |
415 | 331 | | |
| |||
418 | 334 | | |
419 | 335 | | |
420 | 336 | | |
421 | | - | |
| 337 | + | |
422 | 338 | | |
423 | 339 | | |
424 | 340 | | |
425 | 341 | | |
426 | 342 | | |
427 | 343 | | |
428 | 344 | | |
429 | | - | |
| 345 | + | |
430 | 346 | | |
431 | 347 | | |
432 | 348 | | |
| |||
436 | 352 | | |
437 | 353 | | |
438 | 354 | | |
439 | | - | |
| 355 | + | |
440 | 356 | | |
441 | 357 | | |
442 | 358 | | |
| |||
This file was deleted.
0 commit comments