diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2015-11-02 11:55:14 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2015-11-02 11:55:14 +1100 |
commit | fb6ebe75207c3221314ed318595489a838ef1db0 (patch) | |
tree | 6b9b210b15f9b9685b9a5dd707001297127ee1d3 /src/third_party/wiredtiger/src/session/session_compact.c | |
parent | 4fbfa13ec0f819080a35ed8b528a030797e483a6 (diff) | |
download | mongo-fb6ebe75207c3221314ed318595489a838ef1db0.tar.gz |
Import wiredtiger-wiredtiger-mongodb-3.2.0-rc1-194-g0dc3f20.tar.gz from wiredtiger branch mongodb-3.2
Diffstat (limited to 'src/third_party/wiredtiger/src/session/session_compact.c')
-rw-r--r-- | src/third_party/wiredtiger/src/session/session_compact.c | 61 |
1 files changed, 41 insertions, 20 deletions
diff --git a/src/third_party/wiredtiger/src/session/session_compact.c b/src/third_party/wiredtiger/src/session/session_compact.c index bbd4bbc536c..bd503cd7826 100644 --- a/src/third_party/wiredtiger/src/session/session_compact.c +++ b/src/third_party/wiredtiger/src/session/session_compact.c @@ -146,24 +146,12 @@ __session_compact_check_timeout( static int __compact_file(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) { - WT_DECL_RET; + struct timespec start_time; WT_DECL_ITEM(t); - WT_SESSION *wt_session; - WT_TXN *txn; + WT_DECL_RET; int i; - struct timespec start_time; - - txn = &session->txn; - wt_session = &session->iface; - - /* - * File compaction requires checkpoints, which will fail in a - * transactional context. Check now so the error message isn't - * confusing. - */ - if (session->compact->file_count != 0 && F_ISSET(txn, WT_TXN_RUNNING)) - WT_ERR_MSG(session, EINVAL, - " File compaction not permitted in a transaction"); + const char *checkpoint_cfg[] = { + WT_CONFIG_BASE(session, WT_SESSION_checkpoint), NULL, NULL }; /* * Force the checkpoint: we don't want to skip it because the work we @@ -171,6 +159,7 @@ __compact_file(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) */ WT_ERR(__wt_scr_alloc(session, 128, &t)); WT_ERR(__wt_buf_fmt(session, t, "target=(\"%s\"),force=1", uri)); + checkpoint_cfg[1] = t->data; WT_ERR(__wt_epoch(session, &start_time)); @@ -182,7 +171,7 @@ __compact_file(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) * time through the loop. */ for (i = 0; i < 100; ++i) { - WT_ERR(wt_session->checkpoint(wt_session, t->data)); + WT_ERR(__wt_txn_checkpoint(session, checkpoint_cfg)); session->compaction = false; WT_WITH_SCHEMA_LOCK(session, @@ -192,8 +181,8 @@ __compact_file(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) if (!session->compaction) break; - WT_ERR(wt_session->checkpoint(wt_session, t->data)); - WT_ERR(wt_session->checkpoint(wt_session, t->data)); + WT_ERR(__wt_txn_checkpoint(session, checkpoint_cfg)); + WT_ERR(__wt_txn_checkpoint(session, checkpoint_cfg)); WT_ERR(__session_compact_check_timeout(session, start_time)); } @@ -212,10 +201,24 @@ __wt_session_compact( WT_CONFIG_ITEM cval; WT_DECL_RET; WT_SESSION_IMPL *session; + WT_TXN *txn; session = (WT_SESSION_IMPL *)wt_session; SESSION_API_CALL(session, compact, config, cfg); + if (F_ISSET(S2C(session), WT_CONN_IN_MEMORY)) + WT_ERR(ENOTSUP); + + /* Disallow objects in the WiredTiger name space. */ + WT_ERR(__wt_str_name_check(session, uri)); + + if (!WT_PREFIX_MATCH(uri, "colgroup:") && + !WT_PREFIX_MATCH(uri, "file:") && + !WT_PREFIX_MATCH(uri, "index:") && + !WT_PREFIX_MATCH(uri, "lsm:") && + !WT_PREFIX_MATCH(uri, "table:")) + WT_ERR(__wt_bad_object_type(session, uri)); + /* Setup the structure in the session handle */ memset(&compact, 0, sizeof(WT_COMPACT)); session->compact = &compact; @@ -231,9 +234,27 @@ __wt_session_compact( if (session->compact->lsm_count != 0) WT_ERR(__wt_schema_worker( session, uri, NULL, __wt_lsm_compact, cfg, 0)); - if (session->compact->file_count != 0) + if (session->compact->file_count != 0) { + /* + * File compaction requires checkpoints, which will fail in a + * transactional context. Check now so the error message isn't + * confusing. + */ + txn = &session->txn; + if (F_ISSET(txn, WT_TXN_RUNNING)) + WT_ERR_MSG(session, EINVAL, + " File compaction not permitted in a transaction"); + WT_ERR(__compact_file(session, uri, cfg)); + } err: session->compact = NULL; + + /* + * Release common session resources (for example, checkpoint may acquire + * significant reconciliation structures/memory). + */ + WT_TRET(__wt_session_release_resources(session)); + API_END_RET_NOTFOUND_MAP(session, ret); } |