Skip to content

wrong metric from renewLock() function #18493

@linliu-code

Description

@linliu-code

Bug Description

What happened:
StorageBasedLockProvider.renewLock()

long oldExpirationMs = getLock().getValidUntilMs();
// ... renewal succeeds, lock updated to new expiration (lockExpirationMs) ...
hoodieLockMetrics.ifPresent(metrics -> metrics.updateLockExpirationDeadlineMetric(
    (int) (oldExpirationMs - getCurrentEpochMs())));
// Value: ~30000 ms (remaining time on the PREVIOUS lease, not the new one)

After every heartbeat renewal the metric drops from ~300s to ~30s, then jumps back to ~300s on the next tryLock. This produces a misleading sawtooth pattern on dashboards.

Note: the log message on the next line intentionally uses oldExpirationMs to report the heartbeat margin — that's correct and useful. Only the metric is wrong.

What you expected:
Metrics to report the correct expiration time.

Steps to reproduce:
1.
2.
3.

Environment

Hudi version:
Query engine: (Spark/Flink/Trino etc)
Relevant configs:

Logs and Stack Trace

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugBug reports and fixes

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions