Databases 4 min read

Debugging a NullPointerException During ShardingSphere Startup Caused by TiDB View Metadata

The article details a NullPointerException that occurs when ShardingSphere starts, explains how null values in TiDB‑generated view metadata trigger the error, describes the step‑by‑step investigation and reproduction using TiUP, and discusses several possible fixes and a call for community contributions.

IT Services Circle
IT Services Circle
IT Services Circle
Debugging a NullPointerException During ShardingSphere Startup Caused by TiDB View Metadata

While working with ShardingSphere, the author encountered a NullPointerException (NPE) during startup. The error does not affect normal operation but appears in the logs, prompting a detailed debugging process.

The NPE was traced to the metadata loading phase where ShardingSphere reads column information from information_schema.columns . A TreeMap lookup of dataTypeMap.get(dataType) returned null , leading to the exception.

Further investigation revealed that the null values originated from a TiDB view used in the production environment. Unlike the local and test environments that use MySQL, the production TiDB view contains many null or malformed column type entries, which caused the map lookup to fail.

To reproduce the issue, the author installed a TiDB playground using TiUP:

1. curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
2. source ${your_shell_profile}
3. tiup playground

After creating the problematic view locally and debugging, the author observed that dataTypeMap.get(dataType) returned the string "null" instead of a valid type, confirming the root cause.

Several remediation ideas were considered:

Remove the TiDB view entirely and avoid the problematic operation.

Change the map value type to Integer , though this would require extensive code modifications.

Skip loading view metadata altogether, as the view is rarely used.

The author invites the community to submit a pull request with a proper fix.

debuggingJavadatabasemetadataTiDBShardingSphereNullPointerException
IT Services Circle
Written by

IT Services Circle

Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.