void wts_salvage(void) { WT_CONNECTION *conn; WT_SESSION *session; int ret; conn = g.wts_conn; track("salvage", 0ULL, NULL); /* * Save a copy of the interesting files so we can replay the salvage * step as necessary. */ if ((ret = system( "cd RUNDIR && " "rm -rf slvg.copy && " "mkdir slvg.copy && " "cp WiredTiger* wt* slvg.copy/")) != 0) die(ret, "salvage copy step failed"); if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) die(ret, "connection.open_session"); if ((ret = session->salvage(session, g.uri, NULL)) != 0) die(ret, "session.salvage: %s", g.uri); if ((ret = session->close(session, NULL)) != 0) die(ret, "session.close"); }
/* * salvage -- * A single salvage. */ static void salvage(void) { WT_CONNECTION *conn; WT_SESSION *session; conn = g.wts_conn; track("salvage", 0ULL, NULL); testutil_check(conn->open_session(conn, NULL, NULL, &session)); testutil_check(session->salvage(session, g.uri, "force=true")); testutil_check(session->close(session, NULL)); }
/* * salvage -- * A single salvage. */ static void salvage(void) { WT_CONNECTION *conn; WT_DECL_RET; WT_SESSION *session; conn = g.wts_conn; track("salvage", 0ULL, NULL); testutil_check(conn->open_session(conn, NULL, NULL, &session)); if ((ret = session->salvage(session, g.uri, "force=true")) != 0) testutil_die(ret, "session.salvage: %s", g.uri); testutil_check(session->close(session, NULL)); }
/* * process -- * Salvage, verify and dump the created file. */ void process(void) { FILE *fp; WT_CONNECTION *conn; WT_CURSOR *cursor; const char *key, *value; WT_SESSION *session; char config[100]; /* Salvage. */ config[0] = '\0'; if (verbose) snprintf(config, sizeof(config), "error_prefix=\"%s\",verbose=[salvage,verify],", progname); strcat(config, "log=(enabled=false),"); CHECK(wiredtiger_open(NULL, NULL, config, &conn) == 0); CHECK(conn->open_session(conn, NULL, NULL, &session) == 0); CHECK(session->salvage(session, "file:" SLVG, 0) == 0); CHECK(conn->close(conn, 0) == 0); /* Verify. */ CHECK(wiredtiger_open(NULL, NULL, config, &conn) == 0); CHECK(conn->open_session(conn, NULL, NULL, &session) == 0); CHECK(session->verify(session, "file:" SLVG, 0) == 0); CHECK(conn->close(conn, 0) == 0); /* Dump. */ CHECK((fp = fopen(DUMP, "w")) != NULL); CHECK(wiredtiger_open(NULL, NULL, config, &conn) == 0); CHECK(conn->open_session(conn, NULL, NULL, &session) == 0); CHECK(session->open_cursor( session, "file:" SLVG, NULL, "dump=print", &cursor) == 0); while (cursor->next(cursor) == 0) { if (page_type == WT_PAGE_ROW_LEAF) { CHECK(cursor->get_key(cursor, &key) == 0); CHECK(fputs(key, fp) >= 0); CHECK(fputc('\n', fp) >= 0); } CHECK(cursor->get_value(cursor, &value) == 0); CHECK(fputs(value, fp) >= 0); CHECK(fputc('\n', fp) >= 0); } CHECK(conn->close(conn, 0) == 0); CHECK(fclose(fp) == 0); }
/* * salvage -- * A single salvage. */ static void salvage(void) { WT_CONNECTION *conn; WT_SESSION *session; int ret; conn = g.wts_conn; track("salvage", 0ULL, NULL); if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) die(ret, "connection.open_session"); if ((ret = session->salvage(session, g.uri, "force=true")) != 0) die(ret, "session.salvage: %s", g.uri); if ((ret = session->close(session, NULL)) != 0) die(ret, "session.close"); }
Status WiredTigerKVEngine::_salvageIfNeeded(const char* uri) { // Using a side session to avoid transactional issues WiredTigerSession sessionWrapper(_conn); WT_SESSION* session = sessionWrapper.getSession(); int rc = (session->verify)(session, uri, NULL); if (rc == 0) { log() << "Verify succeeded on uri " << uri << ". Not salvaging."; return Status::OK(); } if (rc == EBUSY) { // SERVER-16457: verify and salvage are occasionally failing with EBUSY. For now we // lie and return OK to avoid breaking tests. This block should go away when that ticket // is resolved. error() << "Verify on " << uri << " failed with EBUSY. Assuming no salvage is needed."; return Status::OK(); } // TODO need to cleanup the sizeStorer cache after salvaging. log() << "Verify failed on uri " << uri << ". Running a salvage operation."; return wtRCToStatus(session->salvage(session, uri, NULL), "Salvage failed:"); }