Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-50639][SQL] Improve warning logging in CacheManager #49276

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vrozov
Copy link
Member

@vrozov vrozov commented Dec 23, 2024

What changes were proposed in this pull request?

The change improves warning logging in the CacheManager by:

  1. Adds logical plan info to the existing warning messages.
  2. Logs warning message in case an attempt is made to remove data from the cache, but data is not present.

Why are the changes needed?

The change helps to identify incorrect calls to Dataset.persist() and Dataset.unpersist() as in

Dataset<Row> dataset = ...
Dataset<Row> dataset1 = dataset.withColumn(...);
Dataset<Row> dataset2 = dataset1.withColumn(...);
dataset.persist(); // OK
dataset1.persist(); // OK
dataset.persist(); // currently logs warning without logical plan details
dataset.unpersist(); // OK
dataset.unpersist(); // no warning
dataset2.unpersist(); // no warning, the actual call should be on dataset1

Does this PR introduce any user-facing change?

Users may see warning messages like:

23.12.2024 19:15:03.840 WARN  [pool-30-thread-1] org.apache.spark.sql.execution.CacheManager - An attempt was made to cache data even though the data had already been cached. Please un-cache data or clear cache first.
Logical plan:
Relation [i#0] JDBCRelation(test_table) [numPartitions=1]

and

23.12.2024 19:15:04.207 WARN  [pool-30-thread-1] org.apache.spark.sql.execution.CacheManager - Data has not been previously cached or it was removed from the cache already.
Logical plan:
Project [i#0, i#0 AS year#6]
+- Relation [i#0] JDBCRelation(test_table) [numPartitions=1]

How was this patch tested?

The change modifies warning log messages.

Was this patch authored or co-authored using generative AI tooling?

No.

@github-actions github-actions bot added the SQL label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant