Prechádzať zdrojové kódy

Merge pull request #426 from richardkchapman/gh-424_roxie_queryset

Fix gh-424 Roxie fails to load rest of queryset if any query fails
Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 13 rokov pred
rodič
commit
4cf57726bc

+ 2 - 0
common/workunit/workunit.cpp

@@ -8787,6 +8787,8 @@ void addQueryToQuerySet(IWorkUnit *workunit, const char *querySetName, const cha
     SCMStringBuffer dllName;
     Owned<IConstWUQuery> q = workunit->getQuery();
     q->getQueryDllName(dllName);
+    if (!dllName.length())
+        throw MakeStringException(WUERR_InvalidDll, "Cannot deploy query - no associated dll.");
 
     SCMStringBuffer wuid;
     workunit->getWuid(wuid);

+ 1 - 0
common/workunit/wuerror.hpp

@@ -47,5 +47,6 @@
 #define WUERR_ScheduleLockFailed                5021
 #define WUERR_PackageAlreadyExists              5022
 #define WUERR_MismatchClusterType               5023
+#define WUERR_InvalidDll                        5024
 
 #endif

+ 30 - 12
roxie/ccd/ccdstate.cpp

@@ -669,20 +669,28 @@ public:
             ForEach (*queryNames)
             {
                 const IPropertyTree &query = queryNames->query();
-                const char *id = query.queryProp("@id");
-                const char *dllName = query.queryProp("@dll");
-                if (!id || !dllName)
+                try
                 {
-                    StringBuffer qxml;
+                    const char *id = query.queryProp("@id");
+                    const char *dllName = query.queryProp("@dll");
+                    if (!id || !*id || !dllName || !*dllName)
+                        throw MakeStringException(ROXIE_QUERY_MODIFICATION, "dll and id must be specified");
+                    Owned<const IQueryDll> queryDll = createQueryDll(dllName);
+                    const IRoxiePackage *package = packages.queryPackage(id);
+                    if (!package) package = packages.queryPackage("default");
+                    if (!package) package = packages.queryRootPackage();
+                    assertex(package);
+                    addQuery(id, loadQueryFromDll(id, queryDll.getClear(), *package, &query));
+                }
+                catch (IException *E)
+                {
+                    // we don't want a single bad query in the set to stop us loading all the others
+                    StringBuffer msg, qxml;
                     toXML(&query, qxml);
-                    throw MakeStringException(ROXIE_QUERY_MODIFICATION, "Invalid query definition %s: dll and id must be specified", qxml.str());
+                    msg.appendf("Failed to load query: %s", qxml.str());
+                    EXCLOG(E, msg.str());
+                    E->Release();
                 }
-                Owned<const IQueryDll> queryDll = createQueryDll(dllName);
-                const IRoxiePackage *package = packages.queryPackage(id);
-                if (!package) package = packages.queryPackage("default");
-                if (!package) package = packages.queryRootPackage();
-                assertex(package);
-                addQuery(id, loadQueryFromDll(id, queryDll.getClear(), *package, &query));
             }
 
             Owned<IPropertyTreeIterator> a = querySet.getElements("Alias");
@@ -691,7 +699,17 @@ public:
                 IPropertyTree &item = a->query();
                 const char *alias = item.queryProp("@name"); 
                 const char *original = item.queryProp("@id");
-                addAlias(alias, original);
+                try
+                {
+                    addAlias(alias, original);
+                }
+                catch (IException *E)
+                {
+                    // we don't want a single bad alias in the set to stop us loading all the others
+                    VStringBuffer msg("Failed to set alias %s on %s", alias, original);
+                    EXCLOG(E, msg.str());
+                    E->Release();
+                }
             }
         }
     }