Exemplo n.º 1
0
    def test_open_index_and_drop(self):
        # We should also be able to detect cached cursors
        # for indices
        session = self.session
        uri = 'table:test_cursor13_drops'
        ds = ComplexDataSet(self, uri, 100)
        ds.create()
        indexname = ds.index_name(0)
        c = session.open_cursor(indexname)
        # The index is really open, so we cannot drop the main table.
        self.assertRaises(wiredtiger.WiredTigerError,
            lambda: session.drop(uri))
        c.close()
        session.drop(uri)
        confirm_does_not_exist(self, uri)

        # Same test for indices, but with cursor held by another session.
        # TODO: try with session that DOES have cache_cursors and another
        # that does not.
        session2 = self.conn.open_session(None)
        ds = ComplexDataSet(self, uri, 100)
        ds.create()
        indexname = ds.index_name(0)
        c = session2.open_cursor(indexname)
        self.assertRaises(wiredtiger.WiredTigerError,
            lambda: session.drop(uri))
        c.close()
        session.drop(uri)
        confirm_does_not_exist(self, uri)
        session2.close()
Exemplo n.º 2
0
    def test_open_index_and_drop(self):
        # We should also be able to detect cached cursors
        # for indices
        session = self.session
        uri = 'table:test_cursor13_drops'
        ds = ComplexDataSet(self, uri, 100)
        ds.create()
        indexname = ds.index_name(0)
        c = session.open_cursor(indexname)
        # The index is really open, so we cannot drop the main table.
        self.assertRaises(wiredtiger.WiredTigerError,
                          lambda: session.drop(uri))
        c.close()
        session.drop(uri)
        confirm_does_not_exist(self, uri)

        # Same test for indices, but with cursor held by another session.
        # TODO: try with session that DOES have cache_cursors and another
        # that does not.
        session2 = self.conn.open_session(None)
        ds = ComplexDataSet(self, uri, 100)
        ds.create()
        indexname = ds.index_name(0)
        c = session2.open_cursor(indexname)
        self.assertRaises(wiredtiger.WiredTigerError,
                          lambda: session.drop(uri))
        c.close()
        session.drop(uri)
        confirm_does_not_exist(self, uri)
        session2.close()
Exemplo n.º 3
0
    def test_bug025(self):
        ds = ComplexDataSet(self, self.uri, self.nrows, key_format="S", value_format='S')
        ds.populate()
        iname = ds.index_name(0)
        iname_suffix = iname[iname.rindex(':') + 1:]
        filename = 'test_bug025_' + iname_suffix + '.wti'
        self.close_conn()
        pos = os.path.getsize(filename) - 1024
        os.remove(filename)

        # We get an error message, but the open succeeds.
        with self.expectedStderrPattern('.*No such file or directory'):
            self.open_conn()

        newkey = ds.key(self.nrows)
        newval = ds.value(self.nrows)
        cursor = self.session.open_cursor(self.uri)

        # We get an error message, and the insert fails.
        # The cursor remains open.
        with self.expectedStderrPattern('.*No such file or directory'):
            try:
                cursor[newkey] = newval
            except Exception as e:
                self.pr('Exception in first access: ' + str(e))

        # We get an error message, and the insert fails.
        # Before the associated fix was made, the insert crashed.
        with self.expectedStderrPattern('.*No such file or directory'):
            try:
                cursor[newkey] = newval    # point of crash
            except Exception as e:
                self.pr('Exception in second access: ' + str(e))

        cursor.close()
Exemplo n.º 4
0
    def test_bug025(self):
        ds = ComplexDataSet(self,
                            self.uri,
                            self.nrows,
                            key_format="S",
                            value_format='S')
        ds.populate()
        iname = ds.index_name(0)
        iname_suffix = iname[iname.rindex(':') + 1:]
        filename = 'test_bug025_' + iname_suffix + '.wti'
        self.close_conn()
        pos = os.path.getsize(filename) - 1024
        os.remove(filename)

        # We will get error output, but not always in the same API calls from run to run,
        # in particular the open connection doesn't always report the missing file, as
        # index files are usually lazily loaded. As long as the missing file is reported
        # at least once in the following code, it's good.
        with self.expectedStderrPattern('.*No such file or directory.*'):
            self.open_conn()

            newkey = ds.key(self.nrows)
            newval = ds.value(self.nrows)
            cursor = self.session.open_cursor(self.uri)

            # The insert fails, and the cursor remains open.
            try:
                cursor[newkey] = newval
            except Exception as e:
                self.pr('Exception in first access: ' + str(e))

            # The insert fails again.  Before the associated fix was made, the insert crashed.
            try:
                cursor[newkey] = newval  # point of crash
            except Exception as e:
                self.pr('Exception in second access: ' + str(e))

            cursor.close()