fix(emr): give Hive one AWS SDK on emr-6.x images (#7921)

A Hive step or an EMR Serverless Hive run on a table in S3 failed on
emr-6.15.0 with NoSuchFieldError: AWS_S3_DISABLE_EXPRESS_SESSION_AUTH as
soon as S3A built its client.

Those images' Hive lib folder has the stock AWS SDK v2 modules, and the
S3 client is only in Tez's plug-in, EMR's own build of the SDK, later on
the class path, so that client ran on the stock sdk-core.

The modules the plug-in also holds now go, by name, before Hive starts,
while the container is still root: in a Hive run's wrapper, and in the
primary node's script, as the metastore service opens a table's S3
location with S3A too. An image with no loose sdk-core, as emr-7.5.0 and
emr-7.10.0 have, or without the plug-in keeps every jar.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-10 22:48:01 -06:00
1 parent 9eb3ba38ed
commit 173141c5f2
4 files changed
+74

No files matched your search

@@ -144,6 +144,7 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
"address=$FLOCI_HDFS_BIND; [ \"$address\" != 0.0.0.0 ] || address=$(hostname -i | awk '{print $1}')",
"echo \"$address $FLOCI_HDFS_HOST\" >> /etc/hosts || exit",
"chown hadoop:hadoop /mnt || exit",
EmrServerlessSparkRunner.HIVE_ONE_SDK,
"mkdir -p " + HDFS_CONF + " || exit",
"printf '%s\\n' '<configuration>'"
+ " \"<property><name>fs.defaultFS</name><value>hdfs://$FLOCI_HDFS_HOST:8020</value></property>\""
@@ -260,6 +260,19 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
* path, apart from the one its other steps' Hadoop reads; Hive runs with it where an image has it.
*/
public static final String HIVE_HADOOP_CONF = "/etc/hadoop/conf.hive";
private static final String HIVE_LIB = "/usr/lib/hive/lib";
/**
* Leaves Hive one AWS SDK v2, before Hive starts, as root. An {@code emr-6.x} Hive image's lib folder has the stock
* SDK's modules, ahead on Hive's class path of the SDK inside Tez's plug-in, EMR's own build and the only one with
* an S3 client. S3A, which {@code s3://} is here, then builds the plug-in's S3 client on the stock {@code sdk-core},
* which on {@code emr-6.15.0} fails with {@code NoSuchFieldError: AWS_S3_DISABLE_EXPRESS_SESSION_AUTH}. The modules
* the plug-in also holds go, by name, which is all but CloudWatch's two.
*/
public static final String HIVE_ONE_SDK = "for core in " + HIVE_LIB + "/sdk-core-2.*.jar; do"
+ " [ -e /usr/lib/tez/tez-emr-serverless.jar ] && for module in annotations apache-client auth aws-core"
+ " aws-json-protocol aws-query-protocol endpoints-spi http-client-spi json-utils metrics-spi"
+ " netty-nio-client profiles protocol-core regions sdk-core third-party-jackson-core utils;"
+ " do rm -f \"" + HIVE_LIB + "/$module-${core##*/sdk-core-}\"; done; done";
private static final String HIVE_SCRATCHDIR = "hive.exec.scratchdir";
// The user every EMR Serverless image runs as: a custom one sets "the USER back to hadoop:hadoop".
private static final String IMAGE_USER = "hadoop";
@@ -281,6 +294,7 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
+ HIVE_SCRATCH_VARIABLE + "\" || exit",
"fi",
"if [ -d " + HIVE_HADOOP_CONF + " ]; then export HADOOP_CONF_DIR=" + HIVE_HADOOP_CONF + "; fi",
HIVE_ONE_SDK,
"export HOME=~" + IMAGE_USER,
"cd \"$HOME\" || exit",
// The image's user has no other group, as Docker starts it.