Repository navigation
Conversation
|
Merged build triggered. |
|
Merged build started. |
|
Merged build finished. |
|
Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/15851/ |
There was a problem hiding this comment.
"val classServerListenPort: Int" - word "port" make it obvious, that it's Int. There is no need for such specification
|
Merged build triggered. |
|
Merged build started. |
|
Merged build finished. |
|
Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/16258/ |
|
Merged build triggered. |
|
Merged build started. |
|
With these changes, I think I'm able to make this work for the majority case. There will still need to be some work done to handle the situation where a Spark application is run on the same machine as a worker though. Currently the application will take the port of an executor and cause the executor on one server to be on port n+1 while all others are on port n. This occurs for Fresh cluster, no applications: The connections can be summarized as:
After starting spark-shell like this: These are summarized as:
The outstanding things I'd like to do for this still are:
And lower priority:
Because all the ports being listened on ("*:40010" etc) are specified now though I think this is moving closer to being ready. |
|
Merged build finished. |
|
Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/16259/ |
|
Merged build triggered. |
|
Merged build started. |
|
Merged build finished. All automated tests passed. |
|
All automated tests passed. |
|
@ash211 do you mind bringing this up to date? I'd like to do a review and merge in the next few days. |
Uses spark.fileserver.port
Uses spark.broadcast.port
spark.replClassServer.port
spark.blockManager.port
Fails when running master+worker+executor+shell on the same machine. I think the issue is that both the shell and the executor attempt to start a ConnectionManager, which causes port conflicts. Solution is to attempt and increment on BindExceptions
- spark.fileserver.port - spark.broadcast.port - spark.replClassServer.port - spark.blockManager.port
There was a problem hiding this comment.
could this be called requestedPort to make it a bit more clear?
|
@ash211 made some small comments but overall looks good. One thing - have you tested this on a cluster? I want to make sure we cover every possible connection here (I wonder if there are some we might have missed). I think the only real way to do it is to totally lock down a cluster and see if Spark can run. |
|
I haven't tested this on an actual locked down cluster yet -- it's just
|
|
Looking at netstat more closely, we realized that there is still a port that's not configurable: the port that the driver connects to the executor on with Akka. The worker connects to its executor on this port as well, but because that's a local connection it's not as important from the firewall perspective. Looking at the master branch now, it also looks like the driverPropsFetcher right before needs a configurable port as well. |
|
Yeah good call, we need to cover that one as well. |
There was a problem hiding this comment.
This doesn't do anything I believe
|
Hey @ash211 I think @andrewor14 is gonna take a stab at fixing these issues so we can get it merged today. We're passed the window on this release and I want to make sure it goes in so people can test it. We'll include all of your comitts and just add a few changes on top of them. |
|
Sounds great -- my apologies for not being on top of responding to the code On Mon, Aug 4, 2014 at 6:31 PM, Patrick Wendell notifications@github.com
|
|
No problem, thanks for working on this @ash211 |
The goal of this PR is to allow users of Spark to write tight firewall rules for their clusters. This is currently not possible because Spark uses random ports in many places, notably the communication between executors and drivers. The changes in this PR are based on top of ash211's changes in #1107. The list covered here may or may not be the complete set of port needed for Spark to operate perfectly. However, as of the latest commit there are no known sources of random ports (except in tests). I have not documented a few of the more obscure configs. My spark-env.sh looks like this: ``` export SPARK_MASTER_PORT=6060 export SPARK_WORKER_PORT=7070 export SPARK_MASTER_WEBUI_PORT=9090 export SPARK_WORKER_WEBUI_PORT=9091 ``` and my spark-defaults.conf looks like this: ``` spark.master spark://andrews-mbp:6060 spark.driver.port 5001 spark.fileserver.port 5011 spark.broadcast.port 5021 spark.replClassServer.port 5031 spark.blockManager.port 5041 spark.executor.port 5051 ``` Author: Andrew Or <andrewor14@gmail.com> Author: Andrew Ash <andrew@andrewash.com> Closes #1777 from andrewor14/configure-ports and squashes the following commits: 621267b [Andrew Or] Merge branch 'master' of github.com:apache/spark into configure-ports 8a6b820 [Andrew Or] Use a random UI port during tests 7da0493 [Andrew Or] Fix tests 523c30e [Andrew Or] Add test for isBindCollision b97b02a [Andrew Or] Minor fixes c22ad00 [Andrew Or] Merge branch 'master' of github.com:apache/spark into configure-ports 93d359f [Andrew Or] Executors connect to wrong port when collision occurs d502e5f [Andrew Or] Handle port collisions when creating Akka systems a2dd05c [Andrew Or] Patrick's comment nit 86461e2 [Andrew Or] Remove spark.executor.env.port and spark.standalone.client.port 1d2d5c6 [Andrew Or] Fix ports for standalone cluster mode cb3be88 [Andrew Or] Various doc fixes (broken link, format etc.) e837cde [Andrew Or] Remove outdated TODOs bfbab28 [Andrew Or] Merge branch 'master' of github.com:apache/spark into configure-ports de1b207 [Andrew Or] Update docs to reflect new ports b565079 [Andrew Or] Add spark.ports.maxRetries 2551eb2 [Andrew Or] Remove spark.worker.watcher.port 151327a [Andrew Or] Merge branch 'master' of github.com:apache/spark into configure-ports 9868358 [Andrew Or] Add a few miscellaneous ports 6016e77 [Andrew Or] Add spark.executor.port 8d836e6 [Andrew Or] Also document SPARK_{MASTER/WORKER}_WEBUI_PORT 4d9e6f3 [Andrew Or] Fix super subtle bug 3f8e51b [Andrew Or] Correct erroneous docs... e111d08 [Andrew Or] Add names for UI services 470f38c [Andrew Or] Special case non-"Address already in use" exceptions 1d7e408 [Andrew Or] Treat 0 ports specially + return correct ConnectionManager port ba32280 [Andrew Or] Minor fixes 6b550b0 [Andrew Or] Assorted fixes 73fbe89 [Andrew Or] Move start service logic to Utils ec676f4 [Andrew Or] Merge branch 'SPARK-2157' of github.com:ash211/spark into configure-ports 038a579 [Andrew Ash] Trust the server start function to report the port the service started on 7c5bdc4 [Andrew Ash] Fix style issue 0347aef [Andrew Ash] Unify port fallback logic to a single place 24a4c32 [Andrew Ash] Remove type on val to match surrounding style 9e4ad96 [Andrew Ash] Reformat for style checker 5d84e0e [Andrew Ash] Document new port configuration options 066dc7a [Andrew Ash] Fix up HttpServer port increments cad16da [Andrew Ash] Add fallover increment logic for HttpServer c5a0568 [Andrew Ash] Fix ConnectionManager to retry with increment b80d2fd [Andrew Ash] Make Spark's block manager port configurable 17c79bb [Andrew Ash] Add a configuration option for spark-shell's class server f34115d [Andrew Ash] SPARK-1176 Add port configuration for HttpBroadcast 49ee29b [Andrew Ash] SPARK-1174 Add port configuration for HttpFileServer 1c0981a [Andrew Ash] Make port in HttpServer configurable (cherry picked from commit 09f7e45) Signed-off-by: Patrick Wendell <pwendell@gmail.com>
The goal of this PR is to allow users of Spark to write tight firewall rules for their clusters. This is currently not possible because Spark uses random ports in many places, notably the communication between executors and drivers. The changes in this PR are based on top of ash211's changes in #1107. The list covered here may or may not be the complete set of port needed for Spark to operate perfectly. However, as of the latest commit there are no known sources of random ports (except in tests). I have not documented a few of the more obscure configs. My spark-env.sh looks like this: ``` export SPARK_MASTER_PORT=6060 export SPARK_WORKER_PORT=7070 export SPARK_MASTER_WEBUI_PORT=9090 export SPARK_WORKER_WEBUI_PORT=9091 ``` and my spark-defaults.conf looks like this: ``` spark.master spark://andrews-mbp:6060 spark.driver.port 5001 spark.fileserver.port 5011 spark.broadcast.port 5021 spark.replClassServer.port 5031 spark.blockManager.port 5041 spark.executor.port 5051 ``` Author: Andrew Or <andrewor14@gmail.com> Author: Andrew Ash <andrew@andrewash.com> Closes #1777 from andrewor14/configure-ports and squashes the following commits: 621267b [Andrew Or] Merge branch 'master' of github.com:apache/spark into configure-ports 8a6b820 [Andrew Or] Use a random UI port during tests 7da0493 [Andrew Or] Fix tests 523c30e [Andrew Or] Add test for isBindCollision b97b02a [Andrew Or] Minor fixes c22ad00 [Andrew Or] Merge branch 'master' of github.com:apache/spark into configure-ports 93d359f [Andrew Or] Executors connect to wrong port when collision occurs d502e5f [Andrew Or] Handle port collisions when creating Akka systems a2dd05c [Andrew Or] Patrick's comment nit 86461e2 [Andrew Or] Remove spark.executor.env.port and spark.standalone.client.port 1d2d5c6 [Andrew Or] Fix ports for standalone cluster mode cb3be88 [Andrew Or] Various doc fixes (broken link, format etc.) e837cde [Andrew Or] Remove outdated TODOs bfbab28 [Andrew Or] Merge branch 'master' of github.com:apache/spark into configure-ports de1b207 [Andrew Or] Update docs to reflect new ports b565079 [Andrew Or] Add spark.ports.maxRetries 2551eb2 [Andrew Or] Remove spark.worker.watcher.port 151327a [Andrew Or] Merge branch 'master' of github.com:apache/spark into configure-ports 9868358 [Andrew Or] Add a few miscellaneous ports 6016e77 [Andrew Or] Add spark.executor.port 8d836e6 [Andrew Or] Also document SPARK_{MASTER/WORKER}_WEBUI_PORT 4d9e6f3 [Andrew Or] Fix super subtle bug 3f8e51b [Andrew Or] Correct erroneous docs... e111d08 [Andrew Or] Add names for UI services 470f38c [Andrew Or] Special case non-"Address already in use" exceptions 1d7e408 [Andrew Or] Treat 0 ports specially + return correct ConnectionManager port ba32280 [Andrew Or] Minor fixes 6b550b0 [Andrew Or] Assorted fixes 73fbe89 [Andrew Or] Move start service logic to Utils ec676f4 [Andrew Or] Merge branch 'SPARK-2157' of github.com:ash211/spark into configure-ports 038a579 [Andrew Ash] Trust the server start function to report the port the service started on 7c5bdc4 [Andrew Ash] Fix style issue 0347aef [Andrew Ash] Unify port fallback logic to a single place 24a4c32 [Andrew Ash] Remove type on val to match surrounding style 9e4ad96 [Andrew Ash] Reformat for style checker 5d84e0e [Andrew Ash] Document new port configuration options 066dc7a [Andrew Ash] Fix up HttpServer port increments cad16da [Andrew Ash] Add fallover increment logic for HttpServer c5a0568 [Andrew Ash] Fix ConnectionManager to retry with increment b80d2fd [Andrew Ash] Make Spark's block manager port configurable 17c79bb [Andrew Ash] Add a configuration option for spark-shell's class server f34115d [Andrew Ash] SPARK-1176 Add port configuration for HttpBroadcast 49ee29b [Andrew Ash] SPARK-1174 Add port configuration for HttpFileServer 1c0981a [Andrew Ash] Make port in HttpServer configurable
|
Of course. Thanks for getting this in and dealing with the fallout I saw come through |
The goal of this PR is to allow users of Spark to write tight firewall rules for their clusters. This is currently not possible because Spark uses random ports in many places, notably the communication between executors and drivers. The changes in this PR are based on top of ash211's changes in apache#1107. The list covered here may or may not be the complete set of port needed for Spark to operate perfectly. However, as of the latest commit there are no known sources of random ports (except in tests). I have not documented a few of the more obscure configs. My spark-env.sh looks like this: ``` export SPARK_MASTER_PORT=6060 export SPARK_WORKER_PORT=7070 export SPARK_MASTER_WEBUI_PORT=9090 export SPARK_WORKER_WEBUI_PORT=9091 ``` and my spark-defaults.conf looks like this: ``` spark.master spark://andrews-mbp:6060 spark.driver.port 5001 spark.fileserver.port 5011 spark.broadcast.port 5021 spark.replClassServer.port 5031 spark.blockManager.port 5041 spark.executor.port 5051 ``` Author: Andrew Or <andrewor14@gmail.com> Author: Andrew Ash <andrew@andrewash.com> Closes apache#1777 from andrewor14/configure-ports and squashes the following commits: 621267b [Andrew Or] Merge branch 'master' of github.com:apache/spark into configure-ports 8a6b820 [Andrew Or] Use a random UI port during tests 7da0493 [Andrew Or] Fix tests 523c30e [Andrew Or] Add test for isBindCollision b97b02a [Andrew Or] Minor fixes c22ad00 [Andrew Or] Merge branch 'master' of github.com:apache/spark into configure-ports 93d359f [Andrew Or] Executors connect to wrong port when collision occurs d502e5f [Andrew Or] Handle port collisions when creating Akka systems a2dd05c [Andrew Or] Patrick's comment nit 86461e2 [Andrew Or] Remove spark.executor.env.port and spark.standalone.client.port 1d2d5c6 [Andrew Or] Fix ports for standalone cluster mode cb3be88 [Andrew Or] Various doc fixes (broken link, format etc.) e837cde [Andrew Or] Remove outdated TODOs bfbab28 [Andrew Or] Merge branch 'master' of github.com:apache/spark into configure-ports de1b207 [Andrew Or] Update docs to reflect new ports b565079 [Andrew Or] Add spark.ports.maxRetries 2551eb2 [Andrew Or] Remove spark.worker.watcher.port 151327a [Andrew Or] Merge branch 'master' of github.com:apache/spark into configure-ports 9868358 [Andrew Or] Add a few miscellaneous ports 6016e77 [Andrew Or] Add spark.executor.port 8d836e6 [Andrew Or] Also document SPARK_{MASTER/WORKER}_WEBUI_PORT 4d9e6f3 [Andrew Or] Fix super subtle bug 3f8e51b [Andrew Or] Correct erroneous docs... e111d08 [Andrew Or] Add names for UI services 470f38c [Andrew Or] Special case non-"Address already in use" exceptions 1d7e408 [Andrew Or] Treat 0 ports specially + return correct ConnectionManager port ba32280 [Andrew Or] Minor fixes 6b550b0 [Andrew Or] Assorted fixes 73fbe89 [Andrew Or] Move start service logic to Utils ec676f4 [Andrew Or] Merge branch 'SPARK-2157' of github.com:ash211/spark into configure-ports 038a579 [Andrew Ash] Trust the server start function to report the port the service started on 7c5bdc4 [Andrew Ash] Fix style issue 0347aef [Andrew Ash] Unify port fallback logic to a single place 24a4c32 [Andrew Ash] Remove type on val to match surrounding style 9e4ad96 [Andrew Ash] Reformat for style checker 5d84e0e [Andrew Ash] Document new port configuration options 066dc7a [Andrew Ash] Fix up HttpServer port increments cad16da [Andrew Ash] Add fallover increment logic for HttpServer c5a0568 [Andrew Ash] Fix ConnectionManager to retry with increment b80d2fd [Andrew Ash] Make Spark's block manager port configurable 17c79bb [Andrew Ash] Add a configuration option for spark-shell's class server f34115d [Andrew Ash] SPARK-1176 Add port configuration for HttpBroadcast 49ee29b [Andrew Ash] SPARK-1174 Add port configuration for HttpFileServer 1c0981a [Andrew Ash] Make port in HttpServer configurable
…ssions (#1107) * [SPARK-40609][SQL] Casts types according to bucket info for Equality expressions * Update TypeCoercion.scala
…Base (apache#1107) Co-authored-by: Egor Krivokon <>
…ssion (apache#1107) ### What changes were proposed in this pull request? The date, interval and integer kernels' answer checks now run without a Spark session, through the expression harness that the coverage and TIME suites already use. `VarkaDifferentialSuite` keeps the 27 tests that need a session. **This PR sits on apache#1106, which sits on apache#1105.** Its own commits are the last two. - **`VarkaDifferentialHarnessSuite`** holds 68 of the old suite's 94 tests, under their old names, over the same tables. The tables are now SQL `VALUES` with the old nullability: where the old table declared a column nullable that holds no null, an all-null row goes into the `VALUES` and is filtered out again. Without it, Spark would read the column as non-nullable, and the optimizer would rewrite some queries; `coalesce(d, d2)`, for example, would become `d`. - **`VarkaHarnessCases`** now lets one test run its queries in parts, each with its own table, ANSI mode and emit options, as the old tests set them between queries. Each query states what the old test asserted of the plan and the node's metrics: | Expectation | Old assertion | |---|---| | something fused, and a kernel answered a batch | `checkDifferential(..., expectFused = true)` | | something fused | `assertFused` alone | | fused whole and served every batch | `numFallbackBatchesDeclined === 0` beside a kernel run | | fused whole, and a kernel declined a batch with its own status | `numFallbackBatchesDeclined > 0` | | nothing fused | `expectFused = false` | Where the old test read verbose `EXPLAIN`, the harness checks the same lines from `VarkaFusionReport`: `"far: residual (day range ["`, `"kernel 2 of 2"` and the others. - **Two changes to how the harness runs a query:** - *Filters:* the filter evaluator is handed only the conjuncts the compiler fuses. That is what `VarkaColumnarRule` hands the Varka node, leaving the rest to a row filter above it. The evaluator compiles only a condition that fuses whole, so without this a filter with one residual conjunct fell back on every batch. - *The row consumer:* it now compares only the outputs `projectFused` returns. Projections with residual or forwarded entries therefore run through the row node's path too. - **`VarkaDifferentialSuite`** keeps what needs a session: - the plan around the Varka nodes: a narrowing projection absorbed, a residual conjunct's row filter and the order Spark evaluates conjuncts in, a projection stacked on a filter's compacted batch, the common-expression hoist; - the fallback hooks and the metrics they move; - AQE, aggregation, the cache's batches, tasks sharing a kernel class, a non-Arrow source, the SQL UI's residual count, Metaspace; - the `guardDayProducers=false` test, which asserts only the metric, never the wrong values that configuration produces; the harness compares every answer; - the `ILLEGAL_DAY_OF_WEEK` error a user sees. No coverage row raises that condition, so no other session test shows it. - **`VarkaSharedSessions`** drops the seven fixtures no suite reads any more. - **`VarkaHarnessParitySuite`** plans every hand-written query of both harness suites in a session, under its part's ANSI mode, and requires each expression to equal the harness's. - **`skips.tsv`:** - 11 lines follow their tests to the new suite. - The `arrowBatchSize=1` line for "null-as-false, and the boundary selectivities" is removed. Its reason was the in-memory scan's statistics pruning one-row batches, and the harness has no scan, so the test now passes there. - **Docs:** `ADDING_AN_EXPRESSION.md` and `docs/sql-varka.md` now point to the harness suite. ### Why are the changes needed? The suite spent its time on session work. It ran each query through two sessions, sorted the results, and ran the query a second time for the warm cache. It took 66 s at the defaults on the laptop, and 3.66 h of the option matrix's run 40658422887. The checks need only the expressions and the batches. | Configuration | Before (old suite) | After (harness suite + session suite) | |---|---|---| | defaults | 66 s | 4.1 s + 36.7 s | | `arrowBatchSize=1` | 70 s | 4.6 s + 36.4 s | Results, with each of the 94 old tests mapped to where its check now lives: `sql/varka/plans/m8/results/VARKA-509-step3b-local.txt`. ### Does this PR introduce _any_ user-facing change? No. Tests only. ### How was this patch tested? - All 1,211 tests of the harness and session suites this work touches pass at the defaults, in one JVM. That includes the coverage suites and the 68 new tests. - I ran the six configurations that have skip lines for these tests locally: `checkIntOverflow=false`, `guardDayProducers=false`, `guardUnderArm=false`, `severalKernels=false`, `arrowBatchSize=1` and `validityByWidth=false`. Each test cancels where its line says, and nothing else fails. The CI matrix covers the other configurations. - `build/sbt 'sql/testOnly *VarkaDifferentialHarnessSuite'` runs the 68 tests, as `ADDING_AN_EXPRESSION.md` now says. - The linters pass. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 5.5)
…aved (apache#1111) ### What changes were proposed in this pull request? This measures what the previous pull requests saved by checking Varka's answers in a harness without a Spark session instead of through one. The coverage, differential and time-arithmetic suites are measured on the laptop, in the pull request's Build and in the option matrix. The PR also adds the script that reads the CI numbers. - `sql/varka/plans/m8/results/VARKA-509-step4.txt`: - **Laptop, at the defaults:** the suites take 135.8 s where they took 472.2, with 1,211 tests against 1,172. - **Pull request's Build:** the Varka jobs spend 399.3 s on them against 1,064.1. The longest sql job takes 24 minutes against 33. - **Option matrix:** their configuration-hours fall from 11.96 to 1.61, and the run's suite-hours from 35.30 to 22.61. - **Matrix wall time:** it went from 58 minutes to 45, set by the run's longest bin rather than by its total work. - `dev/varka_matrix_run.py`: one run's cost, from the Actions API and the artifacts the run uploads. - For an option-matrix run: its wall time, bins, JVM time, and each suite's hours under the configurations. - For a Build: its sql and catalyst test jobs' minutes, and each named suite's seconds, from either the full module jobs or the Varka-scoped jobs. - The plan marks the task done. The profile after the move, in `VARKA-510-planning-local.txt` (merged with apache#1108), shows where the time goes now. ### Why are the changes needed? The move had to be measured against the cost it set out to cut, and the measurement found two costs that affect the next steps: - **The reach recording.** The Build records which configurations change what each test compiles, so the matrix can skip unchanged tests. That recording doubles a harness suite's time in the Build: 45 s plain against 92 s recording for the three harness suites on the laptop. We keep it, because it lets the matrix skip what a configuration doesn't change. - **Query planning.** With the session gone, the harness's largest cost is Spark's analyzer and optimizer, planning one tiny query at a time. The two "before" Builds were checked for comparability. The first Build of step 1 predates the reach recording, the three-job split and the sort-page fix, so it isn't used. The before is step 1's last Build, which has all three, like the after. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - `dev/varka_matrix_run.py --self-test`; ruff check and ruff format. - `dev/varka_plan_lint.py --check` and `dev/varka_quote_check.py` are clean. - The Java and Scala linters don't apply: this changes no Java or Scala. - **No option matrix is dispatched.** This PR changes no code the matrix runs, and apache#1107's matrix (run 40855387471) passed on the same tree of code. This PR is stacked on apache#1107. Until apache#1107 merges, its diff also shows apache#1107's files. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 5.5)
https://issues.apache.org/jira/browse/SPARK-2157
This pull request adds the ability to specify every port opened by Spark that I could find to configure. Specifically, it adds the following four configuration options:
spark.fileserver.portspark.broadcast.portspark.replClassServer.portspark.blockManager.portOf those options, most will attempt to fall back to the n+1 incremental port if the port is currently in use. This incremental fallback logic is done for :
spark.broadcast.portspark.blockManager.portspark.replClassServer.portBut not for
spark.fileserver.portThings still thinking about for this PR:
CoarseGrainedExecutorBackendlistening on ephemeral portsspark.driver.portis described as being the way to configure :7077 on Spark Master, and I'm not sure this is the case. If so the same config item is used for multiple things, as it's also the port on which the applications starts listening on Akka.Many thanks to @epahomov whose work this is based off of.