Commit 3b2dd85
[SPARK-51252][SS] Add instance metrics for last uploaded snapshot version in HDFS State Stores
### What changes were proposed in this pull request?
SPARK-51252
Similar to SPARK-51097, This PR sets up instance-specific metrics (`SnapshotLastUploaded.partition_<partition id>_<state store name>` to be precise) in the executor side and publishes them through StreamingQueryProgress. The main difference is that this PR adds the metrics to HDFS state stores to have similar observability to RocksDB state stores.
There are two non-test differences compared to the RocksDB PR:
- Add tracking of lastUploadedSnapshotVersion to HDFS state stores, which is updated in the state store object instead of RocksDB. Also updates at the end of writeUpdates instead of uploadSnapshot.
- Metric creation is done in the state store provider class instead of object
The fixes for SparkUI does not affect this PR, since that was an issue with the underlying instance metrics collection process. I still re-verified that these metrics do not show up on SparkUI (screenshot below)
As for the test changes:
- Modified the RocksDB tests slightly to process some additional data in the queries, because the version difference check used in HDFS and RocksDB state stores uses > and >= respectively. The general structure of the tests remain the same.
### Why are the changes needed?
We would like to introduce a similar level of observability into other types of state stores. As for the metrics themselves, it would be helpful in identifying performance degradation issues behind maintenance tasks and more as described in SPARK-51097.
### Does this PR introduce _any_ user-facing change?
There will be some new metrics displayed from StreamingQueryProgress:
```
Streaming query made progress: {
...
"stateOperators" : [ {
...
"customMetrics" : {
...
"SnapshotLastUploaded.partition_0_default" : 2,
"SnapshotLastUploaded.partition_12_default" : 10,
"SnapshotLastUploaded.partition_8_default" : 10,
...
}
} ],
"sources" : ...,
"sink" : ...
}
```
Similar to its RocksDB variant, the amount of metrics reported is also tuned using `STATE_STORE_INSTANCE_METRICS_REPORT_LIMIT`, and will by default report 5 instance metrics.
### How was this patch tested?
Four new tests are added into a new suite StateStoreInstanceMetricSuite, making eight tests in total for both state stores. Future instance metrics can be included into this suite for testing and verification.
The first two tests execute a dedup streaming query and verifies metrics are properly filtered + updated through the StreamingQueryProgress logs, but with different StateStore providers that skip maintenance tasks for specific partitions.
The other two tests execute a join streaming query, which contains four state stores per partition instead of one. These two tests verifies metrics are properly collected and filtered as well.
Verified the metrics do not show up on Spark UI:

### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #50030 from zecookiez/SPARK-51252-hdfs.
Lead-authored-by: Zeyu Chen <zycm03@gmail.com>
Co-authored-by: Zeyu Chen <ZYCM03@gmail.com>
Signed-off-by: Jungtaek Lim <kabhwan.opensource@gmail.com>1 parent 3155c4b commit 3b2dd85
File tree
4 files changed
+413
-293
lines changed- sql
- connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/streaming
- core/src
- main/scala/org/apache/spark/sql/execution/streaming/state
- test/scala/org/apache/spark/sql/execution/streaming/state
4 files changed
+413
-293
lines changedLines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
Lines changed: 24 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
223 | 233 | | |
224 | 234 | | |
225 | 235 | | |
| |||
386 | 396 | | |
387 | 397 | | |
388 | 398 | | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
389 | 402 | | |
390 | 403 | | |
391 | 404 | | |
| |||
419 | 432 | | |
420 | 433 | | |
421 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
422 | 439 | | |
423 | 440 | | |
424 | 441 | | |
| |||
431 | 448 | | |
432 | 449 | | |
433 | 450 | | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
434 | 454 | | |
435 | 455 | | |
436 | 456 | | |
| |||
677 | 697 | | |
678 | 698 | | |
679 | 699 | | |
| 700 | + | |
| 701 | + | |
680 | 702 | | |
681 | 703 | | |
682 | 704 | | |
| |||
Lines changed: 2 additions & 290 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | | - | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | 33 | | |
47 | 34 | | |
48 | 35 | | |
49 | 36 | | |
50 | | - | |
51 | | - | |
52 | 37 | | |
53 | 38 | | |
54 | 39 | | |
| |||
286 | 271 | | |
287 | 272 | | |
288 | 273 | | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | 274 | | |
0 commit comments