github-actions[bot] commented on code in PR #70903:
URL: https://github.com/apache/doris/pull/70903#discussion_r4668526070
##########
fe/fe-core/src/main/java/org/apache/doris/connector/ConnectorPluginManager.java:
##########
@@ -233,10 +241,14 @@ boolean registerDiscovered(ConnectorProvider provider,
ConnectorSecuritySurface
boolean failFast) {
Review Comment:
[P1] Keep a bad directory provider from aborting all plugin discovery.
`loadPlugins()` invokes `registerDiscovered(..., false)` without a catch, while
this new `getFileFormats()` call runs provider code here. If it throws a
RuntimeException or LinkageError, the exception escapes the partial-success
loader and later valid connector directories never register. Snapshot provider
metadata under the directory-load try/catch, or convert failures to a rejection
that discards/logs this provider, and add a throwing-provider load test.
##########
fe/fe-core/src/main/java/org/apache/doris/connector/ConnectorPluginManager.java:
##########
@@ -299,6 +314,46 @@ private String createTableEngineNameProblem(Set<String>
engineNames) {
return null;
}
+ /**
+ * Same uniqueness rule as the type name, applied to the file formats a
provider claims for the file table
+ * functions, so that a format means one reader whatever the load order.
The formats the engine reads itself
+ * are reserved: a plugin answering to one would change what existing
statements read.
+ */
+ private String fileFormatProblem(Set<String> formats) {
+ for (String format : formats) {
+ if (format == null || format.trim().isEmpty()) {
+ return "getFileFormats() returned a blank format name";
+ }
+ String lower = format.toLowerCase();
+ if (FileFormatProperties.ENGINE_FORMATS.contains(lower)) {
+ return "file format '" + format + "' is reserved for a format
the engine reads itself";
+ }
+ if (fileFormatProviders.containsKey(lower)) {
+ return "file format '" + format + "' is already claimed by
another registered connector provider";
+ }
+ }
+ return null;
+ }
+
+ /**
+ * The reader of {@code format} for the file table functions, or empty
when no plugin claims the format. Its
+ * connector is built through {@link
ConnectorProvider#createFileFormatConnector} when a statement first reads
+ * the format, with the plugin's own conf and no storage, and kept for the
life of the FE.
+ */
+ public Optional<PluginFileFormat> getFileFormat(String format) {
+ String key = format.toLowerCase();
+ ConnectorProvider provider = fileFormatProviders.get(key);
+ if (provider == null) {
+ return Optional.empty();
+ }
Review Comment:
[P1] Pin the file-format plugin lifecycle to its classloader.
`getFileFormat()` invokes `provider.createFileFormatConnector(...)` on the FE
analysis thread here, and `ExternalFileTableValuedFunction.readPluginFormat()`
then calls the plugin metadata/handle/schema methods without a TCCL wrapper. A
directory plugin using ServiceLoader, by-name reflection, or plugin worker
initialization can resolve against the FE application loader, so a valid
`s3(..., \"format\"=...)` fails with a missing provider or split-brain class
cast before planning. Save the caller TCCL, set
`provider.getClass().getClassLoader()` around construction and the complete
file-source metadata sequence, and restore it in `finally`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]