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.
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 playgroundAfter 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.
IT Services Circle
Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.