Repository navigation
Lineage of runs on a Hop Server: the server reports the client's run, part of #9688 - #9719
Conversation
hansva
left a comment
There was a problem hiding this comment.
Thanks for this. I went through the hand-over of a remote run's lineage to the Hop Server and left 13 inline comments. The first five look like real problems: a sink-hold leak on the client (LineageRunLifecycleEmitter:430), a run's lineage lost when the server can't use the client's sinks or the workflow start fails (LineageRemoteRuns:147, RemoteWorkflowEngine:613), START held and stamped late on engines that never hand over (RemoteWorkflowEngine:293), and duplicate START/COMPLETE under one run id for variable sinks (LineageRunLifecycleEmitter:427). The rest are smaller: docs wording, logging, Lombok, and IT robustness.
| * server: only the sinks configured with variables, which get every event, still get its events. | ||
| */ | ||
| private static Set<String> runSinks(IPipelineEngine<PipelineMeta> pipeline) { | ||
| return LineageRemoteRuns.isHandedOver(pipeline) ? Set.of() : LineageSinkRoutes.of(pipeline); |
There was a problem hiding this comment.
Sink holds leak for a handed-over remote pipeline.
When the run is handed over, runSinks() returns Set.of() without ever calling LineageSinkRoutes.of(pipeline). The remote pipeline engine fires PipelineStart only after answered(), so nothing resolves the run's sinks before LineageHubPipelineCompletedXp runs. release(pipeline) then has nothing to release, and the isEnabled(pipeline) call right after it resolves and holds the run-configuration sink plus the inherited parent sinks. Nothing releases those.
Scenario: Hop GUI or a long-lived Hop Server, no HOP_LINEAGE_* variables, pipeline run on a new Hop Server with a run configuration that selects sink marquez. Every run adds a permanent hold on marquez and on the parent workflow's sinks. After the sink is edited, the old version is never retired or shut down, so its threads and HTTP clients pile up.
Suggestion: keep calling LineageSinkRoutes.of(pipeline) here and drop the result when the run is handed over, or skip the resolve in the completed XP once the run has been released.
There was a problem hiding this comment.
Fixed in c1a0e46: the run's sinks are now always resolved and held, and the ones the server reports to are left out of the client's events. release() in the completed XP then lets go of them.
| * | ||
| * @param serverRunId the run id the server reports under, null from a server that doesn't | ||
| */ | ||
| public static void answered(IExtensionData run, String serverRunId) { |
There was a problem hiding this comment.
The client gives up its sinks before the server has accepted them.
The client stops sending the run's events to its sinks as soon as the server returns lineage_run_id. The server answers that at registration (adoptedRunId in the Register servlets) but only resolves the sinks later, in LineageSinkRoutes.remoteSinks. There, a missing sink, a sink type whose plugin isn't installed, or a URL the server can't reach is only logged.
Scenario: the client's run configuration selects a sink at http://localhost:5000 (Marquez on the developer's machine), or a DataHub sink when the server has no DataHub plugin. The server adopts the run, fails to use the sink and logs it. The client is handed over and sends nothing, so the run is missing from that sink. Before this change the sink at least got the run without its transforms.
Suggestion: have the server resolve the client's sinks at registration and return the ones it accepted, and keep the client reporting to the rest.
There was a problem hiding this comment.
Fixed in c1a0e46: the server checks the client's sinks when it registers the run (name in the run's metadata, a sink type, its plugin installed) and answers with the ones it takes. The client keeps reporting to the others, and the server logs why it left each one out. Whether the server can reach a sink's URL only shows on delivery, so the docs now say the URL has to be reachable from the server (localhost there is the server).
| + webResult.getMessage()); | ||
| } | ||
| containerId = webResult.getId(); | ||
| LineageRemoteRuns.answered(this, webResult.getLineageRunId()); |
There was a problem hiding this comment.
Handed over before the server has started the workflow.
answered() runs on the registration reply, before requestStartWorkflow (line 619). If the start then fails, the server never runs the workflow and reports nothing. Meanwhile the client sends its held STARTED and its FAILED (from WorkflowFinish) to Set.of(), so neither side reports the run. Before this change the client's sink got START and FAIL.
Scenario: the server accepts RegisterWorkflowServlet with lineage_run_id but answers the start request with ERROR, for example because the workflow was removed or the start threw.
Suggestion: call answered() only after the start call succeeds, or reset the hand-over flag in the failure path.
There was a problem hiding this comment.
Fixed in c1a0e46: answered() now runs only after requestStartWorkflow returned OK. Same for the pipeline: after the start servlet answered OK, before PipelineStart.
| logChannel, this, HopExtensionPoint.WorkflowStart.id, this); | ||
| // The server may report the run in lineage itself: whether it does is known once it got the | ||
| // run, so the run's lineage start waits until then. | ||
| LineageRemoteRuns.submitting(this); |
There was a problem hiding this comment.
START is held, and stamped late, on every remote workflow engine.
submitting() holds the lineage START until submitToRemoteServer() returns. That includes engines that never hand a run over: AirflowWorkflowEngine publishes the bundle and waits up to the DAG wait timeout, the load-balancing engine retries with backoff, and an older server never hands over. LineageEvent.of stamps the event when it's emitted, so the START time is wrong as well.
Scenario: an Airflow workflow run where the DAG takes 90 s to appear. The START goes out 90 s late with that later timestamp, so the run's duration in Marquez or DataHub is wrong. A load-balanced workflow waiting for capacity shows the same skew.
Suggestion: call submitting() only on the path that passes a run to a Hop Server, or build the START event (with its timestamp) at WorkflowStart and send it later.
There was a problem hiding this comment.
Fixed in c1a0e46: only engines that send the run to a Hop Server hold the START (reportsLineageOnHopServer(), which the Airflow engine overrides to false). The held START keeps the time it started, so a load-balanced run waiting for capacity no longer shifts it.
|
|
||
| /** | ||
| * The sinks a run's own events go to. A client's run that a Hop Server reports leaves them to the | ||
| * server: only the sinks configured with variables, which get every event, still get its events. |
There was a problem hiding this comment.
Variable sinks get duplicate events under one run id.
A handed-over client run still sends its lifecycle to the sinks configured with variables, as this javadoc says, and the server now reports its run under the same client run id. When both client and server have HOP_LINEAGE_* sinks, one run id gets two START and two COMPLETE events. Before this change the two runs had different ids. This breaks the "ends once" rule that the new IT checks for named sinks.
Scenario: Hop GUI and Hop Server both run with HOP_LINEAGE_OPENLINEAGE_URL=http://marquez:5000, and a pipeline runs remotely. Marquez gets START/COMPLETE from the client (engine Remote, no transforms) and START/COMPLETE from the server, all under the client's run id, so the run ends twice with conflicting facets.
Suggestion: when the run is handed over, suppress its lifecycle events to variable sinks too, or don't adopt the client run id for the server's variable sinks.
There was a problem hiding this comment.
Fixed in c1a0e46: the client passes a digest of where its variable sinks report (HOP_LINEAGE_SINK_IDS and the HOP_LINEAGE_*_URL values). When the server's digest matches, it says so in its answer and the client sends nothing there, so the run ends once. When they differ, each side reports to its own variable sinks as before, so a client-only HOP_LINEAGE_* setup keeps getting the run.
| data(run).put(ADOPTED_KEY, remoteRun); | ||
| return remoteRun.runId(); | ||
| } catch (Exception e) { | ||
| logDetailed(log, e); |
There was a problem hiding this comment.
Nit: when the server can't parse HOP_LINEAGE_REMOTE_RUN, adopt() logs "Unable to pass this run's lineage to the Hop Server", which describes the client side, and only at detailed level. At basic level the server then stops adopting without a word, the client reports the run without its transforms, and the server log gives no hint why lineage is split. Use a server-side message and a level an operator sees.
There was a problem hiding this comment.
Done: a server-side message, logged as an error.
| * @return the lineage run id the server reports the run under, or null | ||
| */ | ||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public String getLineageRunId() { |
There was a problem hiding this comment.
Nit: the new lineageRunId has a hand-written getter and fluent setter. The project convention is Lombok (@Getter, or another Lombok accessor) instead of the boilerplate.
There was a problem hiding this comment.
Done: Lombok @Getter on the lineage fields.
| * Adds the client's pipeline run to the variables sent to the server, in place of one the run | ||
| * inherited. Lineage never stops a run: when the run can't be described, nothing is passed. | ||
| */ | ||
| public static void pass(IPipelineEngine<PipelineMeta> pipeline, Map<String, String> variables) { |
There was a problem hiding this comment.
Nit: pass() clears the variable and stores PASSED_RUN_ID, but never clears HANDED_OVER_KEY from an earlier attempt. If a send fails before answered() runs again, isHandedOver() still returns the earlier server's answer, and the run's FAILED event is suppressed. Today the load-balancing engines only retry when no container id was set, so this can't happen yet, but the safety depends on that retry rule. Removing HANDED_OVER_KEY in pass() makes it independent of it.
There was a problem hiding this comment.
Done: pass() now clears HANDED_OVER_KEY as well.
| for (String name : remoteRun.sinks()) { | ||
| try { | ||
| if (Utils.isEmpty(name) | ||
| || !metadataProvider.getSerializer(LineageSink.class).exists(name)) { |
There was a problem hiding this comment.
Nit: exists(name) checks the raw name, but useSink loads variables.resolve(name), so a name containing $ is checked and loaded under two different strings. The client already resolves names in addName, so resolving again on the server, with the server run's variables, is redundant and can change the name. For a sink literally named sink-${ENV}, or a name the server resolves differently, the check passes and load then logs "does not exist". Resolve once (or not at all) on the server and use the same string for both.
There was a problem hiding this comment.
Done: the server uses the name as the client resolved it, for the check and for the load.
| LOG=/tmp/hop-server-lineage-stub.log | ||
| if [ -f /tmp/hop-server-lineage-stub.pid ]; then | ||
| # Left running by an earlier run in this container | ||
| kill "$(cat /tmp/hop-server-lineage-stub.pid)" 2>/dev/null |
There was a problem hiding this comment.
Nit: this kills whatever pid is in the file without checking that it's still the stub, and never waits for port 18092 to be free before starting the new one. If the old stub died and its pid was reused, this kills an unrelated process in the container. If the old stub is slow to exit, the new one fails to bind (the error only goes to the .out file), the health curl reaches the old stub, and when that dies the events are lost, so main-0022 can fail intermittently. Checking the pid's command line (ps -p) and waiting for the port to close would make it robust.
There was a problem hiding this comment.
Done: the script only stops the old pid when /proc/<pid>/cmdline is still the stub, waits for it to exit and for port 18092 to be free, and fails fast when the new stub dies.
… with its transforms and datasets, part of apache#9688
… over after the start, held START keeps its time, same-target HOP_LINEAGE_* sinks reported once, part of apache#9688
hansva
left a comment
There was a problem hiding this comment.
Three places where the client can stop reporting a run that the server then doesn't report to the same destination. The common fix: the server should only claim a sink when its fully resolved, working target matches the client's.
| } | ||
| Set<String> left = new LinkedHashSet<>(); | ||
| for (String key : sinks) { | ||
| if (!handedOver.sinks().contains(LineageSinkTarget.nameOf(key))) { |
There was a problem hiding this comment.
The server accepts a client's sink by name only. refusal loads the name from the server's own metadata and resolves it with the server's variables. Here the client then drops every key whose nameOf(key) matches. If the two sides have a sink with the same name but a different target, the client stops reporting to its own sink. Nothing is logged.
Example: the client's catalog sink points to prod Marquez, and the server's catalog points to dev Marquez, or the URL is ${OL_URL} and the server resolves it differently. The server accepts catalog, the client removes it from the run's sinks, and the whole run (start/end plus the server's transforms) ends up in dev. Prod never sees it.
Suggestion: have the client pass a digest of each resolved target (plugin + settings, like LineageSinkTarget.key()), and have the server accept a sink only when its own resolved key matches.
There was a problem hiding this comment.
Fixed in 9a59087: the client now passes each sink's key (the name plus a digest of its type and resolved settings), and the server takes a sink only when its own sink of that name, resolved with the run's variables on the server, has the same key. A same-named sink that points elsewhere (your catalog example) is refused and logged on the server, and the client keeps reporting to its own.
| } | ||
| Map<String, String> destination = new TreeMap<>(); | ||
| for (String name : engineVariables.getVariableNames()) { | ||
| if (LineageVariables.HOP_LINEAGE_SINK_IDS.equals(name) |
There was a problem hiding this comment.
This digest covers only HOP_LINEAGE_SINK_IDS and the HOP_LINEAGE_*_URL variables. Other settings also decide where an event lands, for example HOP_LINEAGE_OPENLINEAGE_NAMESPACE, HOP_LINEAGE_DATAHUB_ENV, HOP_LINEAGE_DATAHUB_PLATFORM_INSTANCE and the API key/token.
Example: client and server use the same Marquez URL, but the client has namespace team-a and the server hop-server. The digests match, the server answers that it reports to the variable sinks, and the client sends nothing. The run appears only under the server's namespace.
Suggestion: hash every HOP_LINEAGE_<SINK>_* setting that decides the destination (namespace, env, instance, credentials), or compare the hub's resolved variable-sink targets instead of the raw variables.
There was a problem hiding this comment.
Fixed in 9a59087: the digest now covers every HOP_LINEAGE_* setting except the hub's queue and batch tuning (namespace, env, platform instance and credentials included), plus the plugin ids of the variable sinks that started. Any difference keeps both sides reporting: a run may be reported twice, but not lost.
| * @return the digest, or null when no sinks are configured with variables | ||
| */ | ||
| static String variableSinksDigest(LineageHub hub, IVariables engineVariables) { | ||
| if (hub == null || !hub.isEnabled() || engineVariables == null) { |
There was a problem hiding this comment.
This only checks hub.isEnabled(). If the server's variable sinks failed to initialize (e.g. a bad truststore) or none are actually configured, the server still returns a matching digest. The client then stops sending its lifecycle events, and the server's emit drops everything, so neither side reports the run.
Suggestion: return null here (so the server answers variableSinks=false) when the hub's sinks failed to initialize or there are none.
There was a problem hiding this comment.
Fixed in 9a59087: the digest comes from LineageHub.variableSinkIds(), the variable sinks that actually started (it starts them if needed). When none are set up or they failed to start, there is no digest and the server answers variableSinks=false.
…olved target, variable-sink digest covers every destination setting and only sinks that started, part of apache#9688
A pipeline or workflow run on a Hop Server now shows up in lineage as one run, the client's, with its transforms and datasets, like a local run. Before, the client reported it without transforms, and the server, if it had a sink, reported an unrelated run of its own.
The client passes its run id, file, parent and the names of its run configuration's lineage sinks with the variables it sends. The server reports the run under that identity, to those sinks and its own, and says so in its register answer; the client then leaves the run to the server. An older server ignores the variable and both report as before. Sinks set up with
HOP_LINEAGE_*variables are unchanged. A run sent as an export brings no metadata, so its sink has to exist on the server; a missing one is logged on the run.New IT
main-0022-lineage-on-hop-server(run-tests-docker.sh PROJECT_NAME=hop_server) fails on main and passes with this change. Beam and Spark runs are the next step of #9688.Part of #9688