/* * __compact_checkpoint -- * Perform a checkpoint for compaction. */ static int __compact_checkpoint(WT_SESSION_IMPL *session) { WT_DECL_RET; WT_TXN_GLOBAL *txn_global; uint64_t txn_gen; /* * Force compaction checkpoints: we don't want to skip it because the * work we need to have done is done in the underlying block manager. */ const char *checkpoint_cfg[] = { WT_CONFIG_BASE(session, WT_SESSION_checkpoint), "force=1", NULL }; /* Checkpoints take a lot of time, check if we've run out. */ WT_RET(__wt_session_compact_check_timeout(session)); if ((ret = __wt_txn_checkpoint(session, checkpoint_cfg, false)) == 0) return (0); WT_RET_BUSY_OK(ret); /* * If there's a checkpoint running, wait for it to complete, checking if * we're out of time. If there's no checkpoint running or the checkpoint * generation number changes, the checkpoint blocking us has completed. */ txn_global = &S2C(session)->txn_global; for (txn_gen = __wt_gen(session, WT_GEN_CHECKPOINT);;) { /* * This loop only checks objects that are declared volatile, * therefore no barriers are needed. */ if (!txn_global->checkpoint_running || txn_gen != __wt_gen(session, WT_GEN_CHECKPOINT)) break; WT_RET(__wt_session_compact_check_timeout(session)); __wt_sleep(2, 0); } return (0); }
/* * __wt_verbose_dump_txn -- * Output diagnostic information about the global transaction state. */ int __wt_verbose_dump_txn(WT_SESSION_IMPL *session) { WT_CONNECTION_IMPL *conn; WT_SESSION_IMPL *sess; WT_TXN_GLOBAL *txn_global; WT_TXN_STATE *s; uint64_t id; uint32_t i, session_cnt; #ifdef HAVE_TIMESTAMPS char hex_timestamp[3][2 * WT_TIMESTAMP_SIZE + 1]; #endif conn = S2C(session); txn_global = &conn->txn_global; WT_RET(__wt_msg(session, "%s", WT_DIVIDER)); WT_RET(__wt_msg(session, "transaction state dump")); WT_RET(__wt_msg(session, "current ID: %" PRIu64, txn_global->current)); WT_RET(__wt_msg(session, "last running ID: %" PRIu64, txn_global->last_running)); WT_RET(__wt_msg(session, "oldest ID: %" PRIu64, txn_global->oldest_id)); #ifdef HAVE_TIMESTAMPS WT_RET(__wt_timestamp_to_hex_string( session, hex_timestamp[0], &txn_global->commit_timestamp)); WT_RET(__wt_msg(session, "commit timestamp: %s", hex_timestamp[0])); WT_RET(__wt_timestamp_to_hex_string( session, hex_timestamp[0], &txn_global->oldest_timestamp)); WT_RET(__wt_msg(session, "oldest timestamp: %s", hex_timestamp[0])); WT_RET(__wt_timestamp_to_hex_string( session, hex_timestamp[0], &txn_global->pinned_timestamp)); WT_RET(__wt_msg(session, "pinned timestamp: %s", hex_timestamp[0])); WT_RET(__wt_timestamp_to_hex_string( session, hex_timestamp[0], &txn_global->stable_timestamp)); WT_RET(__wt_msg(session, "stable timestamp: %s", hex_timestamp[0])); WT_RET(__wt_msg(session, "has_commit_timestamp: %s", txn_global->has_commit_timestamp ? "yes" : "no")); WT_RET(__wt_msg(session, "has_oldest_timestamp: %s", txn_global->has_oldest_timestamp ? "yes" : "no")); WT_RET(__wt_msg(session, "has_pinned_timestamp: %s", txn_global->has_pinned_timestamp ? "yes" : "no")); WT_RET(__wt_msg(session, "has_stable_timestamp: %s", txn_global->has_stable_timestamp ? "yes" : "no")); WT_RET(__wt_msg(session, "oldest_is_pinned: %s", txn_global->oldest_is_pinned ? "yes" : "no")); WT_RET(__wt_msg(session, "stable_is_pinned: %s", txn_global->stable_is_pinned ? "yes" : "no")); #endif WT_RET(__wt_msg(session, "checkpoint running: %s", txn_global->checkpoint_running ? "yes" : "no")); WT_RET(__wt_msg(session, "checkpoint generation: %" PRIu64, __wt_gen(session, WT_GEN_CHECKPOINT))); WT_RET(__wt_msg(session, "checkpoint pinned ID: %" PRIu64, txn_global->checkpoint_state.pinned_id)); WT_RET(__wt_msg(session, "checkpoint txn ID: %" PRIu64, txn_global->checkpoint_state.id)); WT_RET(__wt_msg(session, "oldest named snapshot ID: %" PRIu64, txn_global->nsnap_oldest_id)); WT_ORDERED_READ(session_cnt, conn->session_cnt); WT_RET(__wt_msg(session, "session count: %" PRIu32, session_cnt)); WT_RET(__wt_msg(session, "Transaction state of active sessions:")); /* * Walk each session transaction state and dump information. Accessing * the content of session handles is not thread safe, so some * information may change while traversing if other threads are active * at the same time, which is OK since this is diagnostic code. */ for (i = 0, s = txn_global->states; i < session_cnt; i++, s++) { /* Skip sessions with no active transaction */ if ((id = s->id) == WT_TXN_NONE && s->pinned_id == WT_TXN_NONE) continue; sess = &conn->sessions[i]; WT_RET(__wt_msg(session, "ID: %" PRIu64 ", pinned ID: %" PRIu64 ", metadata pinned ID: %" PRIu64 ", name: %s", id, s->pinned_id, s->metadata_pinned, sess->name == NULL ? "EMPTY" : sess->name)); WT_RET(__wt_verbose_dump_txn_one(sess, &sess->txn)); } return (0); }