Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-301

An optimization to save creating checkpoints stopped us creating a checkpoint on an empty table

    • Type: Icon: Task Task
    • Resolution: Done
    • WT1.3
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      It used to be possible to create a checkpoint on an empty table, that is no longer possible. The checkpoint call returns success, but creating a cursor fails. Creating a checkpoint on an empty table allows for simpler handling of checkpoint cursors.

      The change in behavior was introduced in this commit:
      https://github.com/wiredtiger/wiredtiger/commit/6de0cd586b32095952e4d739b0e5eeb5b84712e2

      The following patch includes a test case that displays the behavior, and a fix to revert the behavior:

      Unable to find source-code formatter for language: `c. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      diff --git a/src/txn/txn_ckpt.c b/src/txn/txn_ckpt.c
      index 3304011..7452aef 100644
      --- a/src/txn/txn_ckpt.c
      +++ b/src/txn/txn_ckpt.c
      @@ -393,7 +393,7 @@ __wt_checkpoint(WT_SESSION_IMPL *session, const char *cfg[])
       	 * ensure a checkpoint happens, but otherwise, the object isn't dirty
       	 * and the existing checkpoints are sufficient.
       	 */
      -	if (btree->modified == 0 && !force)
      +	if (btree->modified == 0 && !force && btree->checkpoint != NULL)
       		goto skip;
       
       	/* Drop checkpoints with the same name as the one we're taking. */
      diff --git a/test/suite/test_checkpoint02.py b/test/suite/test_checkpoint02.py
      new file mode 100644
      index 0000000..7ce648e
      --- /dev/null
      +++ b/test/suite/test_checkpoint02.py
      @@ -0,0 +1,54 @@
      +#!/usr/bin/env python
      +#
      +# Public Domain 2008-2012 WiredTiger, Inc.
      +#
      +# This is free and unencumbered software released into the public domain.
      +#
      +# Anyone is free to copy, modify, publish, use, compile, sell, or
      +# distribute this software, either in source code form or as a compiled
      +# binary, for any purpose, commercial or non-commercial, and by any
      +# means.
      +#
      +# In jurisdictions that recognize copyright laws, the author or authors
      +# of this software dedicate any and all copyright interest in the
      +# software to the public domain. We make this dedication for the benefit
      +# of the public at large and to the detriment of our heirs and
      +# successors. We intend this dedication to be an overt act of
      +# relinquishment in perpetuity of all present and future rights to this
      +# software under copyright law.
      +#
      +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
      +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
      +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
      +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
      +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
      +# OTHER DEALINGS IN THE SOFTWARE.
      +
      +import wiredtiger, wttest
      +from helper import key_populate, simple_populate
      +
      +# test_checkpoint02.py
      +#    Checkpoint of an empty table. 
      +
      +class test_checkpoint(wttest.WiredTigerTestCase):
      +    scenarios = [
      +        ('file', dict(uri='file:checkpoint',fmt='S')),
      +        ('table', dict(uri='table:checkpoint',fmt='S'))
      +        ]
      +
      +    def test_checkpoint(self):
      +        # Build a file with a set of checkpoints, and confirm they all have
      +        # the correct key/value pairs.
      +        self.session.create(self.uri,
      +            "key_format=" + self.fmt + ",value_format=S")
      +
      +	# Take a checkpoint on the empty table.
      +	self.session.checkpoint()
      +
      +	# Verify that the checkpoint is present.
      +        cursor = self.session.open_cursor(
      +            self.uri, None, "checkpoint=WiredTigerCheckpoint")
      +
      +if __name__ == '__main__':
      +    wttest.run()
      

      `

            Assignee:
            keith.bostic@mongodb.com Keith Bostic (Inactive)
            Reporter:
            alexander.gorrod@mongodb.com Alexander Gorrod
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: