feat: report segment index build progress - #790
hfutatzhanghb wants to merge 4 commits into
Conversation
|
Hi, @fangbo . Have opened this new PR. Could you please review this when have free time? Thanks very much !!! |
|
@hfutatzhanghb This is great work for improving the observability of index building. That said, I’m wondering whether adding these metrics is really necessary. At the moment, each segment build corresponds to a Spark task, and Spark jobs already expose task-level metrics such as total tasks, completed tasks, and running tasks. These seem to map directly to total segments and completed segments. What do you think?
|
That is a fair point. Our original motivation was that, when index building is slow, a Spark task may remain in the Running state for a long time, and we would like to know whether it is stuck or still making progress, as well as how far the internal index build has progressed. However, the current implementation only reports progress when a segment task completes, so it does largely overlap with Spark’s task-level metrics. |
|
@fangbo , Thanks very much for your valuable suggestion. |
There was a problem hiding this comment.
❌ Gate recommendation: request changes.
The callback-driven design addresses the prior mid-task observability gap, but this revision cannot build against its declared Lance dependency. Update to a released lance-core artifact containing lance#8823 and verify that dependency across the supported modules before this can be accepted.
| val createdIndex = progressMetrics match { | ||
| case Some(metrics) => | ||
| val progress = SparkIndexBuildProgress.forCurrentTask(indexName, metrics) | ||
| dataset.createIndex(indexOptions, progress) |
There was a problem hiding this comment.
pom.xml still pins lance-core 11.0.0-beta.21, which predates lance#8823 and exposes only createIndex(IndexOptions). This new two-argument call therefore makes every module compiling the shared base fail before tests run. Update the pinned dependency to a published artifact containing that overload, then run the focused callback and heartbeat tests against it.
Reproducer
./mvnw -q -pl lance-spark-3.5_2.13 -am -DskipTests compile
AddIndexExec.scala:848: overloaded method createIndex ... cannot be applied to (IndexOptions, SparkIndexBuildProgress)


Summary
Report distributed
CREATE INDEXprogress using the independent segment architecture.This is a clean replacement for #747. PR #701 replaced the old shared UUID plus
mergeIndexMetadataFTS flow with one uncommitted Lance segment per Spark task followed by an atomiccommitExistingIndexSegmentscall. Lance Core does not expose a progress callback oncreateIndexor segment commit, so this implementation observes progress at the Spark driver boundary as successful segment partitions return.Changes
index build completed segmentsindex build total segmentsSparkContext.runJobdriver result handler so progress is visible before the full job result is available.SQLMetrics.postDriverMetricUpdatesso the SQL listener, status store, and Spark UI receive live updates.parallelize(tasks, tasks.size)produces exactly one segment task per partition, with explicit errors for empty or multi-task partitions.Scope
Progress is reported for eager segment builds: zonemap, bitmap, label list, ngram, bloomfilter, rtree, FTS or inverted, and BTree fragment mode. Range-mode BTree keeps its dedicated path. Deferred and empty-table builds do not launch segment tasks.
This does not restore the removed
mergeIndexMetadatapath and does not change atomic segment commit behavior. When no SQL execution ID exists, Spark skips SQL-listener publication and driver logging remains the informational fallback.Validation
./mvnw spotless:check./mvnw test -pl lance-spark-3.4_2.12 -Dtest=IndexUtilsTest— 34 tests passed./mvnw test -pl lance-spark-3.5_2.12 -Dtest=IndexUtilsTest— 34 tests passed./mvnw test -pl lance-spark-3.5_2.13 -Dtest=IndexUtilsTest— 34 tests passed./mvnw test -pl lance-spark-4.2_2.13 -Dtest=IndexUtilsTestwith JDK 17 — 34 tests passedThe local native listener integration run cannot start because the installed Lance artifact lacks the
darwin-x86-64JNI library; GitHub Actions is the native validation gate.