All posts

Apache XTable RunSync: every option, and why failures exit 0

Every option and dataset field read from the source, the storage defaults and the S3 credentials trap, continuous mode, and the exit codes of four failing runs.

7 min read Lakehouse

TL;DR

RunSync is a small Java program: it reads a YAML dataset config, builds the source provider, and calls the controller once per dataset.

  • It has seven options, and only --datasetConfig is required.
  • partitionSpec is applied to the Hudi source only. tableDataPath becomes the base path of a Hudi target. namespace is split on dots.
  • The Hadoop defaults use the AWS SDK’s DefaultCredentialsProvider for S3, so keys in your own XML are ignored unless you override the provider.
  • --continuousMode reloads the config on every loop, so you add tables by editing a file.
  • A failed sync does not change the exit code. A wrong path, a rejected partition spec and a partial failure all exited 0 in these runs. Only an unreadable config file exited 1.

RunSync is the standalone entry point for table-format conversion, in the xtable-utilities module. It is the same sync the Spark runtime runs, without a Spark job around it. Its inputs and behaviour below are read from the 0.5.0-incubating source, and the exit codes and failures are from runs. The build is in the cheat sheet.

RunSync reads its configs, builds the source provider, runs the controller once per dataset, catches and logs failures, and exits 0 unless a config file cannot be read

What it does

RunSync.main parses the options. It then loads the dataset config, an optional Iceberg catalog config and the Hadoop configuration, and builds the source provider from the converters config. For each dataset it builds a SourceTable and a TargetTable per target format, and calls ConversionController.sync with SyncMode.INCREMENTAL. There is no option for a full sync. The controller picks a snapshot pass by itself when it has to, as the sync internals post explains.

java -jar "$XTABLE_JAR" --datasetConfig trips_sync.yaml

The bundled jar’s main class is RunSync, so -jar is enough. Any other class, such as RunCatalogSync, needs -cp and the class name.

The seven options

Option Short Required What the code does with it
--datasetConfig -d Yes Path to the YAML described below
--hadoopConfig -p No Hadoop XML that overrides the bundled defaults
--convertersConfig -c No YAML that overrides the provider classes per format
--icebergCatalogConfig -i No Iceberg catalog settings, used for any Iceberg source or target
--continuousMode -m No Run on a loop, reloading the configuration each time
--continuousModeInterval -t No Seconds between runs. Defaults to 5. Needs --continuousMode
--help -h No Print usage

The dataset config

Two top-level fields and a list of tables:

sourceFormat: HUDI
targetFormats:
  - ICEBERG
  - DELTA
datasets:
  - tableBasePath: s3a://lakehouse-prod/warehouse/trips
    tableName: trips
    namespace: analytics
    partitionSpec: city_id:VALUE
Field What the code does with it
sourceFormat Key into the converters map. An unknown value fails with the list of known formats
targetFormats One target table per entry. A target equal to the source is skipped
tableBasePath The table root, used for the source and for every target except Hudi when a data path is set
tableDataPath Passed to the source as its data path. For a Hudi target it replaces the base path, which is why Hudi’s .hoodie/ appears under data/
tableName The name given to the source and every target table
namespace Split on . into an array
partitionSpec Put in the Hudi source properties, so it only affects a Hudi source. Examples: city_id:VALUE, order_ts:DAY:yyyy-MM-dd
targetProperties A map of format name to properties, passed to that target. Hudi’s three properties go here

That tableDataPath rule explains the layout in the Iceberg source post: with a data path set, the Hudi target is written under it and Delta and Iceberg stay at the base path.

Where each dataset field ends up: the base path for the source and targets, the data path as the Hudi target's base, the partition spec for Hudi sources only, and the namespace split on dots

One example per source

# Hudi source
sourceFormat: HUDI
datasets:
  - tableBasePath: s3a://lakehouse-prod/warehouse/trips
    tableName: trips
    partitionSpec: city_id:VALUE
# Iceberg source, files outside the base path
sourceFormat: ICEBERG
datasets:
  - tableBasePath: s3a://lakehouse-prod/warehouse/db/trips
    tableDataPath: s3a://lakehouse-prod/warehouse/db/trips/data
    tableName: trips
    namespace: db
# Delta source
sourceFormat: DELTA
datasets:
  - tableBasePath: s3a://lakehouse-prod/warehouse/trips_delta
    tableName: trips_delta

Each needs a targetFormats list as well. Paimon and Parquet follow the same shape, and Parquet needs --convertersConfig, covered in Delta, Paimon and Parquet as sources.

Storage and credentials

RunSync starts from xtable-hadoop-defaults.xml and layers your --hadoopConfig over it. The defaults set the filesystem classes, fs.s3.impl and fs.s3a.impl to S3AFileSystem, fs.gs.impl to GoogleHadoopFileSystem, and for Azure an OAuth auth type with ClientCredsTokenProvider. For both S3 schemes the credentials provider is software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider.

That default is the trap. It reads environment variables, system properties and profiles, so an access key in your XML is ignored and the sync fails with NoAuthWithAWSException: No AWS Credentials provided by DefaultCredentialsProvider. Override the provider in the same file when you pass keys:

<configuration>
  <property><name>fs.s3a.endpoint</name><value>http://minio:9000</value></property>
  <property><name>fs.s3a.path.style.access</name><value>true</value></property>
  <property><name>fs.s3a.access.key</name><value>ACCESS_KEY</value></property>
  <property><name>fs.s3a.secret.key</name><value>SECRET_KEY</value></property>
  <property><name>fs.s3a.aws.credentials.provider</name>
            <value>org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider</value></property>
</configuration>

On AWS itself, leave the defaults and let the instance role supply credentials. For GCS, use application default credentials from the environment. The metadata is written inside the table path, so the identity needs write access there, not just read access. The Azure and GCS paths were not run for this series.

Continuous mode

--continuousMode schedules runSync with scheduleAtFixedRate on a single thread, every --continuousModeInterval seconds, and the default is 5. Each iteration re-reads the dataset config, so tables added or removed in the file take effect on the next pass without a restart. An IOException in an iteration is logged and the loop carries on. Because there is one thread, runs of one process do not overlap, but two processes on the same table do.

A run started with one table and an 8 second interval picked up a second table added to the file 40 seconds later. It then synced both, with no restart.

Reading the result

Success and failure are log lines, not exit codes. The controller logs Sync is successful for the following formats ... and, at error level, Sync failed for the following formats .... RunSync itself catches any exception from a dataset and logs Error running sync for <basePath>, then moves on to the next dataset.

Four runs, with the exit code of each:

Scenario Exit code What the log said
Iceberg path that does not exist 0 NoSuchTableException, then Error running sync for ...
Partial failure: Hudi target rejects a bucket partition, Delta fine 0 Sync failed for the following formats HUDI
--datasetConfig points to a missing file 1 NoSuchFileException
No options at all 0 The usage text

So a scheduler that only checks the exit code will call every one of those runs a success. Check the log instead:

java -jar "$XTABLE_JAR" --datasetConfig trips_sync.yaml 2>&1 | tee sync.log
if grep -qE "Sync failed for the following formats|Error running sync" sync.log; then
  echo "XTable sync failed" >&2
  exit 1
fi

Both patterns matched in the runs above. The wrapper itself is a plain shell check and was not run as a scheduled job.

Common errors

Message Cause
Source format PARQUET is not supported. Known source and target formats are [...] The source format is not in the converters map. Add a converters config
NoSuchTableException: Table does not exist at location tableBasePath is not the Iceberg table directory
NoAuthWithAWSException: No AWS Credentials provided by DefaultCredentialsProvider Keys in --hadoopConfig with the default provider
Target format is not yet supported: <format> No ConversionTarget on the classpath for that format
Bucket partition is not yet supported by Hudi targets A BUCKET partition with a Hudi target

Checked against the source

Claim Where
The seven options and defaults RunSync.OPTIONS
Per-dataset loop, SyncMode.INCREMENTAL, error catch RunSync.syncTableMetdata
Hudi target uses the data path, namespace split, partitionSpec only for Hudi RunSync.getTargetBasePath, targetTableBuilder, syncTableMetdata
Continuous mode RunSync.main
Hadoop defaults xtable-hadoop-defaults.xml
Dataset fields RunSync.DatasetConfig

The four exit codes are from runs of the bundled jar on Java 11. Continuous mode was run as described. Azure and GCS settings were read from the defaults file only.

Key takeaways

RunSync is easy to configure and easy to mistake for succeeding. Know the three fields with side effects (tableDataPath, partitionSpec, namespace), set the S3 credentials provider when you pass keys, and put a log check around the command, because the exit code will not tell you when a sync failed.

References

Trademarks

Apache XTable (incubating), Apache Hudi, Apache Iceberg, Apache Hadoop and Apache are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries. Delta Lake is a trademark of the Linux Foundation. All other marks are the property of their respective owners.

Found this useful?

These posts and tools are free. If one saved you an afternoon, you can buy me a coffee.

Buy me a coffee

Comments

Questions, corrections and reviews are welcome. Sign in with GitHub to post; comments are stored in this site's public GitHub Discussions.