This is an automated email from the ASF dual-hosted git repository. maxgekk pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new 9ec426dd81c5 [SPARK-46592][DOCKER][TEST] OracleIntegrationSuite is flaky because of ORA-04021 9ec426dd81c5 is described below commit 9ec426dd81c579946e869bfeed935743137deda1 Author: Kent Yao <y...@apache.org> AuthorDate: Thu Jan 4 21:44:38 2024 +0300 [SPARK-46592][DOCKER][TEST] OracleIntegrationSuite is flaky because of ORA-04021 ### What changes were proposed in this pull request? This PR mounts `docker-entrypoint-initdb.d` to OracleDocker to set DDL_LOCK_TIMEOUT and retry `alter user system` to ensure the password of SYSTEM user is correctly set. ### Why are the changes needed? https://github.com/apache/spark/actions/runs/7405337059/job/20148144542 https://github.com/apache/spark/actions/runs/7403889993/job/20144539155 https://github.com/apache/spark/actions/runs/7401841987/job/20138483574 Fix test flakiness caused by ORA-04021 ``` 22:09.284 docker-java-stream-568158377 INFO OracleIntegrationSuite: STDOUT: CONTAINER: Resetting SYS and SYSTEM passwords. 24/01/04 04:22:09.284 docker-java-stream-568158377 INFO OracleIntegrationSuite: STDOUT: 24/01/04 04:22:09.284 docker-java-stream-568158377 INFO OracleIntegrationSuite: STDOUT: User altered. 24/01/04 04:22:09.284 docker-java-stream-568158377 INFO OracleIntegrationSuite: STDOUT: 24/01/04 04:22:09.284 docker-java-stream-568158377 INFO OracleIntegrationSuite: STDOUT: ALTER USER SYSTEM IDENTIFIED BY "Th1s1sThe0racle#Pass" 24/01/04 04:22:09.284 docker-java-stream-568158377 INFO OracleIntegrationSuite: STDOUT: * 24/01/04 04:22:09.284 docker-java-stream-568158377 INFO OracleIntegrationSuite: STDOUT: ERROR at line 1: 24/01/04 04:22:09.285 docker-java-stream-568158377 INFO OracleIntegrationSuite: STDOUT: ORA-65048: error encountered when processing the current DDL statement in 24/01/04 04:22:09.285 docker-java-stream-568158377 INFO OracleIntegrationSuite: STDOUT: pluggable database FREEPDB1 24/01/04 04:22:09.285 docker-java-stream-568158377 INFO OracleIntegrationSuite: STDOUT: ORA-04021: timeout occurred while waiting to lock object 24/01/04 04:22:09.285 docker-java-stream-568158377 INFO OracleIntegrationSuite: STDOUT: Help: https://docs.oracle.com/error-help/db/ora-65048/ 24/01/04 04:22:09.285 docker-java-stream-568158377 INFO OracleIntegrationSuite: STDOUT: 24/01/04 04:22:09.285 docker-java-stream-568158377 INFO OracleIntegrationSuite: STDOUT: ``` ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? OracleIntegrationSuite ### Was this patch authored or co-authored using generative AI tooling? no Closes #44594 from yaooqinn/SPARK-46592. Authored-by: Kent Yao <y...@apache.org> Signed-off-by: Max Gekk <max.g...@gmail.com> --- .../spark/sql/jdbc/OracleDatabaseOnDocker.scala | 67 ++++++++++++++++++++++ .../spark/sql/jdbc/OracleIntegrationSuite.scala | 14 +---- .../spark/sql/jdbc/v2/OracleIntegrationSuite.scala | 16 +----- .../spark/sql/jdbc/v2/OracleNamespaceSuite.scala | 16 +----- 4 files changed, 72 insertions(+), 41 deletions(-) diff --git a/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/OracleDatabaseOnDocker.scala b/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/OracleDatabaseOnDocker.scala new file mode 100644 index 000000000000..9b77469b2f8a --- /dev/null +++ b/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/OracleDatabaseOnDocker.scala @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.jdbc + +import java.io.{File, PrintWriter} + +import com.github.dockerjava.api.model._ + +import org.apache.spark.internal.Logging +import org.apache.spark.util.Utils + +class OracleDatabaseOnDocker extends DatabaseOnDocker with Logging { + lazy override val imageName = + sys.env.getOrElse("ORACLE_DOCKER_IMAGE_NAME", "gvenzl/oracle-free:23.3") + val oracle_password = "Th1s1sThe0racle#Pass" + override val env = Map( + "ORACLE_PWD" -> oracle_password, // oracle images uses this + "ORACLE_PASSWORD" -> oracle_password // gvenzl/oracle-free uses this + ) + override val usesIpc = false + override val jdbcPort: Int = 1521 + + override def getJdbcUrl(ip: String, port: Int): String = { + s"jdbc:oracle:thin:system/$oracle_password@//$ip:$port/freepdb1" + } + + override def beforeContainerStart( + hostConfigBuilder: HostConfig, + containerConfigBuilder: ContainerConfig): Unit = { + try { + val dir = Utils.createTempDir() + val writer = new PrintWriter(new File(dir, "install.sql")) + // SPARK-46592: gvenzl/oracle-free occasionally fails to start with the following error: + // 'ORA-04021: timeout occurred while waiting to lock object', when initializing the + // SYSTEM user. This is due to the fact that the default DDL_LOCK_TIMEOUT is 0, which + // means that the lock will no wait. We set the timeout to 30 seconds to try again. + // TODO: This workaround should be removed once the issue is fixed in the image. + // https://github.com/gvenzl/oci-oracle-free/issues/35 + writer.write("ALTER SESSION SET DDL_LOCK_TIMEOUT = 30;") + writer.write(s"""ALTER USER SYSTEM IDENTIFIED BY "$oracle_password";""") + writer.close() + val newBind = new Bind( + dir.getAbsolutePath, + new Volume("/docker-entrypoint-initdb.d"), + AccessMode.ro) + hostConfigBuilder.withBinds(hostConfigBuilder.getBinds :+ newBind: _*) + } catch { + case e: Exception => + logWarning("Failed to create install.sql file", e) + } + } +} diff --git a/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/OracleIntegrationSuite.scala b/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/OracleIntegrationSuite.scala index 4e13d21864fe..0cdff79ef69f 100644 --- a/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/OracleIntegrationSuite.scala +++ b/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/OracleIntegrationSuite.scala @@ -65,19 +65,7 @@ import org.apache.spark.tags.DockerTest class OracleIntegrationSuite extends DockerJDBCIntegrationSuite with SharedSparkSession { import testImplicits._ - override val db = new DatabaseOnDocker { - lazy override val imageName = - sys.env.getOrElse("ORACLE_DOCKER_IMAGE_NAME", "gvenzl/oracle-free:23.3") - val oracle_password = "Th1s1sThe0racle#Pass" - override val env = Map( - "ORACLE_PWD" -> oracle_password, // oracle images uses this - "ORACLE_PASSWORD" -> oracle_password // gvenzl/oracle-free uses this - ) - override val usesIpc = false - override val jdbcPort: Int = 1521 - override def getJdbcUrl(ip: String, port: Int): String = - s"jdbc:oracle:thin:system/$oracle_password@//$ip:$port/freepdb1" - } + override val db = new OracleDatabaseOnDocker override val connectionTimeout = timeout(7.minutes) diff --git a/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/OracleIntegrationSuite.scala b/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/OracleIntegrationSuite.scala index 0c844219aeb5..1badc110347d 100644 --- a/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/OracleIntegrationSuite.scala +++ b/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/OracleIntegrationSuite.scala @@ -26,7 +26,7 @@ import org.apache.spark.{SparkConf, SparkRuntimeException} import org.apache.spark.sql.AnalysisException import org.apache.spark.sql.catalyst.util.CharVarcharUtils.CHAR_VARCHAR_TYPE_STRING_METADATA_KEY import org.apache.spark.sql.execution.datasources.v2.jdbc.JDBCTableCatalog -import org.apache.spark.sql.jdbc.DatabaseOnDocker +import org.apache.spark.sql.jdbc.OracleDatabaseOnDocker import org.apache.spark.sql.types._ import org.apache.spark.tags.DockerTest @@ -75,19 +75,7 @@ class OracleIntegrationSuite extends DockerJDBCIntegrationV2Suite with V2JDBCTes override val catalogName: String = "oracle" override val namespaceOpt: Option[String] = Some("SYSTEM") - override val db = new DatabaseOnDocker { - lazy override val imageName = - sys.env.getOrElse("ORACLE_DOCKER_IMAGE_NAME", "gvenzl/oracle-free:23.3") - val oracle_password = "Th1s1sThe0racle#Pass" - override val env = Map( - "ORACLE_PWD" -> oracle_password, // oracle images uses this - "ORACLE_PASSWORD" -> oracle_password // gvenzl/oracle-free uses this - ) - override val usesIpc = false - override val jdbcPort: Int = 1521 - override def getJdbcUrl(ip: String, port: Int): String = - s"jdbc:oracle:thin:system/$oracle_password@//$ip:$port/freepdb1" - } + override val db = new OracleDatabaseOnDocker override val defaultMetadata: Metadata = new MetadataBuilder() .putLong("scale", 0) diff --git a/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/OracleNamespaceSuite.scala b/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/OracleNamespaceSuite.scala index daffb5a2d4a3..05f38102d410 100644 --- a/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/OracleNamespaceSuite.scala +++ b/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/OracleNamespaceSuite.scala @@ -21,7 +21,7 @@ import java.sql.Connection import scala.jdk.CollectionConverters._ -import org.apache.spark.sql.jdbc.{DatabaseOnDocker, DockerJDBCIntegrationSuite} +import org.apache.spark.sql.jdbc.{DockerJDBCIntegrationSuite, OracleDatabaseOnDocker} import org.apache.spark.sql.util.CaseInsensitiveStringMap import org.apache.spark.tags.DockerTest @@ -57,19 +57,7 @@ class OracleNamespaceSuite extends DockerJDBCIntegrationSuite with V2JDBCNamespa override def excluded: Seq[String] = Seq("listNamespaces: basic behavior", "Drop namespace") - override val db = new DatabaseOnDocker { - lazy override val imageName = - sys.env.getOrElse("ORACLE_DOCKER_IMAGE_NAME", "gvenzl/oracle-free:23.3") - val oracle_password = "Th1s1sThe0racle#Pass" - override val env = Map( - "ORACLE_PWD" -> oracle_password, // oracle images uses this - "ORACLE_PASSWORD" -> oracle_password // gvenzl/oracle-free uses this - ) - override val usesIpc = false - override val jdbcPort: Int = 1521 - override def getJdbcUrl(ip: String, port: Int): String = - s"jdbc:oracle:thin:system/$oracle_password@//$ip:$port/freepdb1" - } + override val db = new OracleDatabaseOnDocker val map = new CaseInsensitiveStringMap( Map("url" -> db.getJdbcUrl(dockerIp, externalPort), --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org