More schema tests, quit immediately on error.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 20 Mar 2008 15:12:12 +0000 (15:12 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 20 Mar 2008 15:12:12 +0000 (15:12 +0000)
org.glite.lb.server/src/bkserverd.c
org.glite.lb.server/src/openserver.c

index 4075070..105ba26 100644 (file)
@@ -707,10 +707,12 @@ int main(int argc, char *argv[])
        if (!dbstring) dbstring = getenv("LBDB");
        if (!dbstring) dbstring = strdup(DEFAULTCS);
                
-
        /* Just check the database and let it be. The slaves do the job. */
        edg_wll_InitContext(&ctx);
-       if (wait_for_open(ctx, dbstring)) return 1;
+       if (wait_for_open(ctx, dbstring)) {
+               edg_wll_FreeContext(ctx);
+               return 1;
+       }
 
        if ((ctx->dbcaps = glite_lbu_DBQueryCaps(ctx->dbctx)) == -1)
        {
index 5052223..fd50f57 100644 (file)
@@ -25,19 +25,31 @@ edg_wll_ErrorCode edg_wll_Open(edg_wll_Context ctx, char *cs)
        }
        if (glite_lbu_DBConnect(ctx->dbctx,cs) != 0) return edg_wll_SetErrorDB(ctx);
 
-       // proxy and server columns added
-       if (glite_lbu_ExecSQL(ctx->dbctx, "DESC jobs", &stmt) <= 0) goto err;
        hit = 0;
-       while (hit < 2 && (ret = glite_lbu_FetchRow(stmt, 1, NULL, cols)) > 0) {
+       // new columns added to jobs
+       if (glite_lbu_ExecSQL(ctx->dbctx, "DESC jobs", &stmt) <= 0) goto err;
+       while (hit < 5 && (ret = glite_lbu_FetchRow(stmt, 1, NULL, cols)) > 0) {
+               assert(ret <= (int)(sizeof cols/sizeof cols[0]));
+               if (strcasecmp(cols[0], "proxy") == 0 ||
+                   strcasecmp(cols[0], "server") == 0 ||
+                   strcasecmp(cols[0], "grey") == 0 ||
+                   strcasecmp(cols[0], "zombie") == 0 ||
+                   strcasecmp(cols[0], "nevents") == 0) hit++;
+               for (i = 0; i < ret; i++) free(cols[i]);
+       }
+       if (ret < 0) goto err;
+       glite_lbu_FreeStmt(&stmt);
+       // new columns added to events
+       if (glite_lbu_ExecSQL(ctx->dbctx, "DESC events", &stmt) <= 0) goto err;
+       while (hit < 6 && (ret = glite_lbu_FetchRow(stmt, 1, NULL, cols)) > 0) {
                assert(ret <= (int)(sizeof cols/sizeof cols[0]));
-               if (strcasecmp(cols[0], "proxy") == 0 || 
-                   strcasecmp(cols[0], "server") == 0) hit++;
+               if (strcasecmp(cols[0], "seqcode") == 0) hit++;
                for (i = 0; i < ret; i++) free(cols[i]);
        }
        if (ret < 0) goto err;
        glite_lbu_FreeStmt(&stmt);
-       if (hit != 2) {
-               ret = edg_wll_SetError(ctx, EINVAL, "old DB schema found, migration to new schema needed");
+       if (hit != 6) {
+               ret = edg_wll_SetError(ctx, EDG_WLL_ERROR_DB_INIT, "old DB schema found, migration to new schema needed");
                goto close_db;
        }
 
@@ -51,7 +63,7 @@ edg_wll_ErrorCode edg_wll_Open(edg_wll_Context ctx, char *cs)
        if (ret < 0) goto err;
        glite_lbu_FreeStmt(&stmt);
        if (hit != 1) {
-               ret = edg_wll_SetError(ctx, EINVAL, "events_flesh table not found, migration to new schema needed");
+               ret = edg_wll_SetError(ctx, EDG_WLL_ERROR_DB_INIT, "events_flesh table not found, migration to new schema needed");
                goto close_db;
        }