~ubuntu-branches/ubuntu/vivid/mariadb-5.5/vivid

« back to all changes in this revision

Viewing changes to storage/tokudb/ft-index/src/tests/test_stress6.cc

  • Committer: Package Import Robot
  • Author(s): James Page, Otto Kekäläinen
  • Date: 2014-02-17 16:51:52 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140217165152-k315d3175g865kkx
Tags: 5.5.35-1
[ Otto Kekäläinen ]
* New upstream release, fixing the following security issues:
  - Buffer overflow in client/mysql.cc (Closes: #737597).
    - CVE-2014-0001
  - http://www.oracle.com/technetwork/topics/security/cpujan2014-1972949.html
    - CVE-2013-5891
    - CVE-2013-5908
    - CVE-2014-0386
    - CVE-2014-0393
    - CVE-2014-0401
    - CVE-2014-0402
    - CVE-2014-0412
    - CVE-2014-0420
    - CVE-2014-0437
* Upstream https://mariadb.atlassian.net/browse/MDEV-4902
  fixes compatibility with Bison 3.0 (Closes: #733002)
* Updated Russian debconf translation (Closes: #734426)
* Updated Japanese debconf translation (Closes: #735284)
* Updated French debconf translation (Closes: #736480)
* Renamed SONAME properly (Closes: #732967)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 
2
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
 
3
/*
 
4
COPYING CONDITIONS NOTICE:
 
5
 
 
6
  This program is free software; you can redistribute it and/or modify
 
7
  it under the terms of version 2 of the GNU General Public License as
 
8
  published by the Free Software Foundation, and provided that the
 
9
  following conditions are met:
 
10
 
 
11
      * Redistributions of source code must retain this COPYING
 
12
        CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
 
13
        DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
 
14
        PATENT MARKING NOTICE (below), and the PATENT RIGHTS
 
15
        GRANT (below).
 
16
 
 
17
      * Redistributions in binary form must reproduce this COPYING
 
18
        CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
 
19
        DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
 
20
        PATENT MARKING NOTICE (below), and the PATENT RIGHTS
 
21
        GRANT (below) in the documentation and/or other materials
 
22
        provided with the distribution.
 
23
 
 
24
  You should have received a copy of the GNU General Public License
 
25
  along with this program; if not, write to the Free Software
 
26
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
27
  02110-1301, USA.
 
28
 
 
29
COPYRIGHT NOTICE:
 
30
 
 
31
  TokuDB, Tokutek Fractal Tree Indexing Library.
 
32
  Copyright (C) 2007-2013 Tokutek, Inc.
 
33
 
 
34
DISCLAIMER:
 
35
 
 
36
  This program is distributed in the hope that it will be useful, but
 
37
  WITHOUT ANY WARRANTY; without even the implied warranty of
 
38
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
39
  General Public License for more details.
 
40
 
 
41
UNIVERSITY PATENT NOTICE:
 
42
 
 
43
  The technology is licensed by the Massachusetts Institute of
 
44
  Technology, Rutgers State University of New Jersey, and the Research
 
45
  Foundation of State University of New York at Stony Brook under
 
46
  United States of America Serial No. 11/760379 and to the patents
 
47
  and/or patent applications resulting from it.
 
48
 
 
49
PATENT MARKING NOTICE:
 
50
 
 
51
  This software is covered by US Patent No. 8,185,551.
 
52
  This software is covered by US Patent No. 8,489,638.
 
53
 
 
54
PATENT RIGHTS GRANT:
 
55
 
 
56
  "THIS IMPLEMENTATION" means the copyrightable works distributed by
 
57
  Tokutek as part of the Fractal Tree project.
 
58
 
 
59
  "PATENT CLAIMS" means the claims of patents that are owned or
 
60
  licensable by Tokutek, both currently or in the future; and that in
 
61
  the absence of this license would be infringed by THIS
 
62
  IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
 
63
 
 
64
  "PATENT CHALLENGE" shall mean a challenge to the validity,
 
65
  patentability, enforceability and/or non-infringement of any of the
 
66
  PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
 
67
 
 
68
  Tokutek hereby grants to you, for the term and geographical scope of
 
69
  the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
 
70
  irrevocable (except as stated in this section) patent license to
 
71
  make, have made, use, offer to sell, sell, import, transfer, and
 
72
  otherwise run, modify, and propagate the contents of THIS
 
73
  IMPLEMENTATION, where such license applies only to the PATENT
 
74
  CLAIMS.  This grant does not include claims that would be infringed
 
75
  only as a consequence of further modifications of THIS
 
76
  IMPLEMENTATION.  If you or your agent or licensee institute or order
 
77
  or agree to the institution of patent litigation against any entity
 
78
  (including a cross-claim or counterclaim in a lawsuit) alleging that
 
79
  THIS IMPLEMENTATION constitutes direct or contributory patent
 
80
  infringement, or inducement of patent infringement, then any rights
 
81
  granted to you under this License shall terminate as of the date
 
82
  such litigation is filed.  If you or your agent or exclusive
 
83
  licensee institute or order or agree to the institution of a PATENT
 
84
  CHALLENGE, then Tokutek may terminate any rights granted to you
 
85
  under this License.
 
86
*/
 
87
 
 
88
#ident "Copyright (c) 2007-2013 Tokutek Inc.  All rights reserved."
 
89
#ident "$Id$"
 
90
#include "test.h"
 
91
 
 
92
#include <stdio.h>
 
93
#include <stdlib.h>
 
94
 
 
95
#include <toku_pthread.h>
 
96
#include <unistd.h>
 
97
#include <memory.h>
 
98
#include <sys/stat.h>
 
99
#include <db.h>
 
100
 
 
101
#include "threaded_stress_test_helpers.h"
 
102
 
 
103
//
 
104
// This test is a form of stress that does operations on a single dictionary:
 
105
// We create a dictionary bigger than the cachetable (around 4x greater).
 
106
// Then, we spawn a bunch of pthreads that do the following:
 
107
//  - scan dictionary forward with bulk fetch
 
108
//  - scan dictionary forward slowly
 
109
//  - scan dictionary backward with bulk fetch
 
110
//  - scan dictionary backward slowly
 
111
//  - update existing values in the dictionary with db->put(DB_YESOVERWRITE)
 
112
//  - do random point queries into the dictionary
 
113
// With the small cachetable, this should produce quite a bit of churn in reading in and evicting nodes.
 
114
// If the test runs to completion without crashing, we consider it a success.
 
115
//
 
116
// This test differs from stress1 in that it grows the database through
 
117
// update operations.
 
118
//
 
119
 
 
120
static int remove_and_recreate_me(DB_TXN *UU(txn), ARG arg, void* UU(operation_extra), void *UU(stats_extra)) {
 
121
    int r;
 
122
    int db_index = myrandom_r(arg->random_data)%arg->cli->num_DBs;
 
123
    DB* db = arg->dbp[db_index];
 
124
    r = (db)->close(db, 0); CKERR(r);
 
125
 
 
126
    char name[30];
 
127
    ZERO_ARRAY(name);
 
128
    get_ith_table_name(name, sizeof(name), db_index);
 
129
 
 
130
    r = arg->env->dbremove(arg->env, null_txn, name, nullptr, 0);
 
131
    CKERR(r);
 
132
 
 
133
    r = db_create(&(arg->dbp[db_index]), arg->env, 0);
 
134
    assert(r == 0);
 
135
    // TODO: Need to call before_db_open_hook() and after_db_open_hook()
 
136
    r = arg->dbp[db_index]->open(arg->dbp[db_index], null_txn, name, nullptr, DB_BTREE, DB_CREATE, 0666);
 
137
    assert(r == 0);
 
138
    return 0;
 
139
}
 
140
 
 
141
static void
 
142
stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
 
143
    //
 
144
    // the threads that we want:
 
145
    //   - one thread constantly updating random values
 
146
    //   - one thread doing table scan with bulk fetch
 
147
    //   - one thread doing table scan without bulk fetch
 
148
    //   - one thread doing random point queries
 
149
    //
 
150
 
 
151
    if (verbose) printf("starting creation of pthreads\n");
 
152
    const int num_threads = 5 + cli_args->num_update_threads + cli_args->num_ptquery_threads;
 
153
    struct arg myargs[num_threads];
 
154
    for (int i = 0; i < num_threads; i++) {
 
155
        arg_init(&myargs[i], dbp, env, cli_args);
 
156
    }
 
157
 
 
158
    struct scan_op_extra soe[4];
 
159
 
 
160
    // make the forward fast scanner
 
161
    soe[0].fast = true;
 
162
    soe[0].fwd = true;
 
163
    soe[0].prefetch = false;
 
164
    myargs[0].lock_type = STRESS_LOCK_SHARED;
 
165
    myargs[0].operation_extra = &soe[0];
 
166
    myargs[0].operation = scan_op;
 
167
 
 
168
    // make the forward slow scanner
 
169
    soe[1].fast = false;
 
170
    soe[1].fwd = true;
 
171
    soe[1].prefetch = false;
 
172
    myargs[1].lock_type = STRESS_LOCK_SHARED;
 
173
    myargs[1].operation_extra = &soe[1];
 
174
    myargs[1].operation = scan_op;
 
175
 
 
176
    // make the backward fast scanner
 
177
    soe[2].fast = true;
 
178
    soe[2].fwd = false;
 
179
    soe[2].prefetch = false;
 
180
    myargs[2].lock_type = STRESS_LOCK_SHARED;
 
181
    myargs[2].operation_extra = &soe[2];
 
182
    myargs[2].operation = scan_op;
 
183
 
 
184
    // make the backward slow scanner
 
185
    soe[3].fast = false;
 
186
    soe[3].fwd = false;
 
187
    soe[3].prefetch = false;
 
188
    myargs[3].lock_type = STRESS_LOCK_SHARED;
 
189
    myargs[3].operation_extra = &soe[3];
 
190
    myargs[3].operation = scan_op;
 
191
 
 
192
    // make the guy that removes and recreates the db
 
193
    myargs[4].lock_type = STRESS_LOCK_EXCL;
 
194
    myargs[4].sleep_ms = 2000; // maybe make this a runtime param at some point
 
195
    myargs[4].operation = remove_and_recreate_me;
 
196
 
 
197
    // make the guy that updates the db
 
198
    struct update_op_args uoe = get_update_op_args(cli_args, NULL);
 
199
    for (int i = 5; i < 5 + cli_args->num_update_threads; ++i) {
 
200
        myargs[i].bounded_element_range = false;
 
201
        myargs[i].lock_type = STRESS_LOCK_SHARED;
 
202
        myargs[i].operation_extra = &uoe;
 
203
        myargs[i].operation = update_op;
 
204
    }
 
205
 
 
206
    // make the guy that does point queries
 
207
    for (int i = 5 + cli_args->num_update_threads; i < num_threads; i++) {
 
208
        myargs[i].lock_type = STRESS_LOCK_SHARED;
 
209
        myargs[i].bounded_element_range = false;
 
210
        myargs[i].operation = ptquery_op_no_check;
 
211
    }
 
212
 
 
213
    run_workers(myargs, num_threads, cli_args->num_seconds, false, cli_args);
 
214
}
 
215
 
 
216
int
 
217
test_main(int argc, char *const argv[]) {
 
218
    struct cli_args args = get_default_args();
 
219
    parse_stress_test_args(argc, argv, &args);
 
220
    stress_test_main(&args);
 
221
    return 0;
 
222
}