-
Notifications
You must be signed in to change notification settings - Fork 44
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
[HWORKS-1416] Close sparks sessions #1370
Changes from 2 commits
b669743
aa075be
043e39b
5746523
4bf3396
3186e1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1097,5 +1097,14 @@ protected String makeQueryName(String queryName, FeatureGroupBase featureGroup) | |
} | ||
return queryName; | ||
} | ||
|
||
|
||
public void closeSparkSession() { | ||
if (getSparkSession() != null) { | ||
try { | ||
getSparkSession().sparkContext().stop(); | ||
} catch (Exception e) { | ||
// No-OP | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why catching the exception in the first place? If something happens in the |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,7 +116,17 @@ public static void main(String[] args) throws Exception { | |
LOGGER.info("Hsfs utils write options: {}", writeOptions); | ||
|
||
if (op.equals("offline_fg_materialization") || op.equals("offline_fg_backfill")) { | ||
SparkEngine.getInstance().streamToHudiTable(streamFeatureGroup, writeOptions); | ||
SparkEngine engine = SparkEngine.getInstance(); | ||
boolean suceeded = false; | ||
try { | ||
engine.streamToHudiTable(streamFeatureGroup, writeOptions); | ||
suceeded = true; | ||
} finally { | ||
LOGGER.info("Closing spark session..."); | ||
engine.closeSparkSession(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would move this code outside the if statement considering that if an exception happens, the job shuts down correctly. |
||
LOGGER.info("Exiting with " + suceeded); | ||
System.exit(suceeded ? 0 : 1); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -292,3 +292,9 @@ def parse_isoformat_date(da: str) -> datetime: | |
import_fg(job_conf) | ||
elif args.op == "run_feature_monitoring": | ||
run_feature_monitoring(job_conf) | ||
|
||
if spark is not None: | ||
try: | ||
spark.stop() | ||
except Exception as e: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you calling
stop()
on the spark context and notclose()
on the Spark session?The spark context is a "component" of the spark session. You want to close the entire session, not a single component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Python side you are correctly closing the session and not just the context.