Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
066d111c
Commit
066d111c
authored
May 13, 2014
by
Rich Prohaska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#237 fix various bulk loader bugs related to nproc ulimit exceeded
parent
c31f461a
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
523 additions
and
94 deletions
+523
-94
ft/ftloader-internal.h
ft/ftloader-internal.h
+3
-1
ft/ftloader.cc
ft/ftloader.cc
+89
-72
ft/ftloader.h
ft/ftloader.h
+2
-1
ft/tests/ftloader-test-bad-generate.cc
ft/tests/ftloader-test-bad-generate.cc
+1
-1
ft/tests/ftloader-test-extractor-errors.cc
ft/tests/ftloader-test-extractor-errors.cc
+1
-1
ft/tests/ftloader-test-extractor.cc
ft/tests/ftloader-test-extractor.cc
+1
-1
ft/tests/ftloader-test-merge-files-dbufio.cc
ft/tests/ftloader-test-merge-files-dbufio.cc
+1
-6
ft/tests/ftloader-test-open.cc
ft/tests/ftloader-test-open.cc
+1
-1
src/loader.cc
src/loader.cc
+21
-10
src/tests/loader-nproc-close.cc
src/tests/loader-nproc-close.cc
+201
-0
src/tests/loader-nproc-create.cc
src/tests/loader-nproc-create.cc
+202
-0
No files found.
ft/ftloader-internal.h
View file @
066d111c
...
...
@@ -245,6 +245,7 @@ struct ft_loader_s {
CACHETABLE
cachetable
;
bool
did_reserve_memory
;
bool
compress_intermediates
;
bool
allow_puts
;
uint64_t
reserved_memory
;
// how much memory are we allowed to use?
/* To make it easier to recover from errors, we don't use FILE*, instead we use an index into the file_infos. */
...
...
@@ -346,7 +347,8 @@ int toku_ft_loader_internal_init (/* out */ FTLOADER *blp,
TOKUTXN
txn
,
bool
reserve_memory
,
uint64_t
reserve_memory_size
,
bool
compress_intermediates
);
bool
compress_intermediates
,
bool
allow_puts
);
void
toku_ft_loader_internal_destroy
(
FTLOADER
bl
,
bool
is_error
);
...
...
ft/ftloader.cc
View file @
066d111c
This diff is collapsed.
Click to expand it.
ft/ftloader.h
View file @
066d111c
...
...
@@ -113,7 +113,8 @@ int toku_ft_loader_open (FTLOADER *bl,
TOKUTXN
txn
,
bool
reserve_memory
,
uint64_t
reserve_memory_size
,
bool
compress_intermediates
);
bool
compress_intermediates
,
bool
allow_puts
);
int
toku_ft_loader_put
(
FTLOADER
bl
,
DBT
*
key
,
DBT
*
val
);
...
...
ft/tests/ftloader-test-bad-generate.cc
View file @
066d111c
...
...
@@ -170,7 +170,7 @@ static void test_extractor(int nrows, int nrowsets, bool expect_fail) {
}
FTLOADER
loader
;
r
=
toku_ft_loader_open
(
&
loader
,
NULL
,
generate
,
NULL
,
N
,
fts
,
dbs
,
fnames
,
compares
,
"tempXXXXXX"
,
ZERO_LSN
,
nullptr
,
true
,
0
,
false
);
r
=
toku_ft_loader_open
(
&
loader
,
NULL
,
generate
,
NULL
,
N
,
fts
,
dbs
,
fnames
,
compares
,
"tempXXXXXX"
,
ZERO_LSN
,
nullptr
,
true
,
0
,
false
,
true
);
assert
(
r
==
0
);
struct
rowset
*
rowset
[
nrowsets
];
...
...
ft/tests/ftloader-test-extractor-errors.cc
View file @
066d111c
...
...
@@ -180,7 +180,7 @@ static void test_extractor(int nrows, int nrowsets, bool expect_fail, const char
sprintf
(
temp
,
"%s/%s"
,
testdir
,
"tempXXXXXX"
);
FTLOADER
loader
;
r
=
toku_ft_loader_open
(
&
loader
,
NULL
,
generate
,
NULL
,
N
,
fts
,
dbs
,
fnames
,
compares
,
"tempXXXXXX"
,
ZERO_LSN
,
nullptr
,
true
,
0
,
false
);
r
=
toku_ft_loader_open
(
&
loader
,
NULL
,
generate
,
NULL
,
N
,
fts
,
dbs
,
fnames
,
compares
,
"tempXXXXXX"
,
ZERO_LSN
,
nullptr
,
true
,
0
,
false
,
true
);
assert
(
r
==
0
);
struct
rowset
*
rowset
[
nrowsets
];
...
...
ft/tests/ftloader-test-extractor.cc
View file @
066d111c
...
...
@@ -402,7 +402,7 @@ static void test_extractor(int nrows, int nrowsets, const char *testdir) {
sprintf
(
temp
,
"%s/%s"
,
testdir
,
"tempXXXXXX"
);
FTLOADER
loader
;
r
=
toku_ft_loader_open
(
&
loader
,
NULL
,
generate
,
NULL
,
N
,
fts
,
dbs
,
fnames
,
compares
,
temp
,
ZERO_LSN
,
nullptr
,
true
,
0
,
false
);
r
=
toku_ft_loader_open
(
&
loader
,
NULL
,
generate
,
NULL
,
N
,
fts
,
dbs
,
fnames
,
compares
,
temp
,
ZERO_LSN
,
nullptr
,
true
,
0
,
false
,
true
);
assert
(
r
==
0
);
struct
rowset
*
rowset
[
nrowsets
];
...
...
ft/tests/ftloader-test-merge-files-dbufio.cc
View file @
066d111c
...
...
@@ -412,7 +412,7 @@ static void test (const char *directory, bool is_error) {
bt_compare_functions
,
"tempxxxxxx"
,
*
lsnp
,
nullptr
,
true
,
0
,
false
);
nullptr
,
true
,
0
,
false
,
true
);
assert
(
r
==
0
);
}
...
...
@@ -500,11 +500,6 @@ static void test (const char *directory, bool is_error) {
assert
(
cthunk
.
n_read
==
N_RECORDS
);
}
}
//printf("%s:%d Destroying\n", __FILE__, __LINE__);
{
int
r
=
queue_destroy
(
bl
->
primary_rowset_queue
);
assert
(
r
==
0
);
}
{
int
r
=
queue_destroy
(
q
);
assert
(
r
==
0
);
...
...
ft/tests/ftloader-test-open.cc
View file @
066d111c
...
...
@@ -143,7 +143,7 @@ static void test_loader_open(int ndbs) {
for
(
i
=
0
;
;
i
++
)
{
set_my_malloc_trigger
(
i
+
1
);
r
=
toku_ft_loader_open
(
&
loader
,
NULL
,
NULL
,
NULL
,
ndbs
,
fts
,
dbs
,
fnames
,
compares
,
""
,
ZERO_LSN
,
nullptr
,
true
,
0
,
false
);
r
=
toku_ft_loader_open
(
&
loader
,
NULL
,
NULL
,
NULL
,
ndbs
,
fts
,
dbs
,
fnames
,
compares
,
""
,
ZERO_LSN
,
nullptr
,
true
,
0
,
false
,
true
);
if
(
r
==
0
)
break
;
}
...
...
src/loader.cc
View file @
066d111c
...
...
@@ -172,6 +172,13 @@ struct __toku_loader_internal {
char
**
inames_in_env
;
/* [N] inames of new files to be created */
};
static
void
free_inames
(
char
**
inames
,
int
n
)
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
toku_free
(
inames
[
i
]);
}
toku_free
(
inames
);
}
/*
* free_loader_resources() frees all of the resources associated with
* struct __toku_loader_internal
...
...
@@ -185,16 +192,15 @@ static void free_loader_resources(DB_LOADER *loader)
toku_destroy_dbt
(
&
loader
->
i
->
err_val
);
if
(
loader
->
i
->
inames_in_env
)
{
for
(
int
i
=
0
;
i
<
loader
->
i
->
N
;
i
++
)
{
if
(
loader
->
i
->
inames_in_env
[
i
])
toku_free
(
loader
->
i
->
inames_in_env
[
i
]);
}
toku_free
(
loader
->
i
->
inames_in_env
);
free_inames
(
loader
->
i
->
inames_in_env
,
loader
->
i
->
N
);
loader
->
i
->
inames_in_env
=
nullptr
;
}
if
(
loader
->
i
->
temp_file_template
)
toku_free
(
loader
->
i
->
temp_file_template
);
toku_free
(
loader
->
i
->
temp_file_template
);
loader
->
i
->
temp_file_template
=
nullptr
;
// loader->i
toku_free
(
loader
->
i
);
loader
->
i
=
NULL
;
loader
->
i
=
nullptr
;
}
}
...
...
@@ -306,6 +312,9 @@ toku_loader_create_loader(DB_ENV *env,
// time to open the big kahuna
char
**
XMALLOC_N
(
N
,
new_inames_in_env
);
for
(
int
i
=
0
;
i
<
N
;
i
++
)
{
new_inames_in_env
[
i
]
=
nullptr
;
}
FT_HANDLE
*
XMALLOC_N
(
N
,
fts
);
for
(
int
i
=
0
;
i
<
N
;
i
++
)
{
fts
[
i
]
=
dbs
[
i
]
->
i
->
ft_handle
;
...
...
@@ -313,7 +322,7 @@ toku_loader_create_loader(DB_ENV *env,
LSN
load_lsn
;
rval
=
locked_load_inames
(
env
,
txn
,
N
,
dbs
,
new_inames_in_env
,
&
load_lsn
,
puts_allowed
);
if
(
rval
!=
0
)
{
toku_free
(
new_inames_in_env
);
free_inames
(
new_inames_in_env
,
N
);
toku_free
(
fts
);
goto
create_exit
;
}
...
...
@@ -331,12 +340,14 @@ toku_loader_create_loader(DB_ENV *env,
ttxn
,
puts_allowed
,
env
->
get_loader_memory_size
(
env
),
compress_intermediates
);
compress_intermediates
,
puts_allowed
);
if
(
rval
!=
0
)
{
toku_free
(
new_inames_in_env
);
free_inames
(
new_inames_in_env
,
N
);
toku_free
(
fts
);
goto
create_exit
;
}
loader
->
i
->
inames_in_env
=
new_inames_in_env
;
toku_free
(
fts
);
...
...
@@ -441,7 +452,7 @@ static void redirect_loader_to_empty_dictionaries(DB_LOADER *loader) {
loader
->
i
->
dbs
,
loader
->
i
->
db_flags
,
loader
->
i
->
dbt_flags
,
0
,
LOADER_DISALLOW_PUTS
,
false
);
lazy_assert_zero
(
r
);
...
...
src/tests/loader-nproc-close.cc
0 → 100644
View file @
066d111c
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2010-2013 Tokutek Inc. All rights reserved."
#ident "$Id$"
#include "test.h"
#include <db.h>
#include <sys/resource.h>
static
int
loader_flags
=
0
;
static
const
char
*
envdir
=
TOKU_TEST_FILENAME
;
static
int
put_multiple_generate
(
DB
*
UU
(
dest_db
),
DB
*
UU
(
src_db
),
DBT_ARRAY
*
UU
(
dest_keys
),
DBT_ARRAY
*
UU
(
dest_vals
),
const
DBT
*
UU
(
src_key
),
const
DBT
*
UU
(
src_val
))
{
return
ENOMEM
;
}
static
void
loader_open_close
(
int
ndb
)
{
int
r
;
char
rmcmd
[
32
+
strlen
(
envdir
)];
snprintf
(
rmcmd
,
sizeof
rmcmd
,
"rm -rf %s"
,
envdir
);
r
=
system
(
rmcmd
);
CKERR
(
r
);
r
=
toku_os_mkdir
(
envdir
,
S_IRWXU
+
S_IRWXG
+
S_IRWXO
);
CKERR
(
r
);
DB_ENV
*
env
;
r
=
db_env_create
(
&
env
,
0
);
CKERR
(
r
);
r
=
env
->
set_generate_row_callback_for_put
(
env
,
put_multiple_generate
);
CKERR
(
r
);
int
envflags
=
DB_INIT_LOCK
|
DB_INIT_LOG
|
DB_INIT_MPOOL
|
DB_INIT_TXN
|
DB_CREATE
|
DB_PRIVATE
;
r
=
env
->
open
(
env
,
envdir
,
envflags
,
S_IRWXU
+
S_IRWXG
+
S_IRWXO
);
CKERR
(
r
);
env
->
set_errfile
(
env
,
stderr
);
DB
*
dbs
[
ndb
];
uint32_t
db_flags
[
ndb
];
uint32_t
dbt_flags
[
ndb
];
for
(
int
i
=
0
;
i
<
ndb
;
i
++
)
{
db_flags
[
i
]
=
DB_NOOVERWRITE
;
dbt_flags
[
i
]
=
0
;
r
=
db_create
(
&
dbs
[
i
],
env
,
0
);
CKERR
(
r
);
char
name
[
32
];
sprintf
(
name
,
"db%d"
,
i
);
r
=
dbs
[
i
]
->
open
(
dbs
[
i
],
NULL
,
name
,
NULL
,
DB_BTREE
,
DB_CREATE
,
0666
);
CKERR
(
r
);
}
DB_TXN
*
txn
;
r
=
env
->
txn_begin
(
env
,
NULL
,
&
txn
,
0
);
CKERR
(
r
);
DB_LOADER
*
loader
;
r
=
env
->
create_loader
(
env
,
txn
,
&
loader
,
ndb
>
0
?
dbs
[
0
]
:
NULL
,
ndb
,
dbs
,
db_flags
,
dbt_flags
,
loader_flags
);
CKERR
(
r
);
struct
rlimit
current_nproc_limit
;
r
=
getrlimit
(
RLIMIT_NPROC
,
&
current_nproc_limit
);
assert
(
r
==
0
);
struct
rlimit
new_nproc_limit
=
current_nproc_limit
;
new_nproc_limit
.
rlim_cur
=
0
;
r
=
setrlimit
(
RLIMIT_NPROC
,
&
new_nproc_limit
);
assert
(
r
==
0
);
r
=
loader
->
close
(
loader
);
if
(
loader_flags
&
LOADER_DISALLOW_PUTS
)
CKERR
(
r
);
else
CKERR2
(
r
,
EAGAIN
);
r
=
setrlimit
(
RLIMIT_NPROC
,
&
current_nproc_limit
);
assert
(
r
==
0
);
r
=
txn
->
abort
(
txn
);
CKERR
(
r
);
for
(
int
i
=
0
;
i
<
ndb
;
i
++
)
{
r
=
dbs
[
i
]
->
close
(
dbs
[
i
],
0
);
CKERR
(
r
);
}
r
=
env
->
close
(
env
,
0
);
CKERR
(
r
);
}
static
void
do_args
(
int
argc
,
char
*
const
argv
[])
{
int
resultcode
;
char
*
cmd
=
argv
[
0
];
argc
--
;
argv
++
;
while
(
argc
>
0
)
{
if
(
strcmp
(
argv
[
0
],
"-h"
)
==
0
)
{
resultcode
=
0
;
do_usage:
fprintf
(
stderr
,
"Usage: %s -h -v -q -p
\n
"
,
cmd
);
exit
(
resultcode
);
}
else
if
(
strcmp
(
argv
[
0
],
"-v"
)
==
0
)
{
verbose
++
;
}
else
if
(
strcmp
(
argv
[
0
],
"-q"
)
==
0
)
{
verbose
--
;
if
(
verbose
<
0
)
verbose
=
0
;
}
else
if
(
strcmp
(
argv
[
0
],
"-p"
)
==
0
)
{
loader_flags
|=
LOADER_DISALLOW_PUTS
;
}
else
if
(
strcmp
(
argv
[
0
],
"-z"
)
==
0
)
{
loader_flags
|=
LOADER_COMPRESS_INTERMEDIATES
;
}
else
if
(
strcmp
(
argv
[
0
],
"-e"
)
==
0
)
{
argc
--
;
argv
++
;
if
(
argc
>
0
)
envdir
=
argv
[
0
];
}
else
{
fprintf
(
stderr
,
"Unknown arg: %s
\n
"
,
argv
[
0
]);
resultcode
=
1
;
goto
do_usage
;
}
argc
--
;
argv
++
;
}
}
int
test_main
(
int
argc
,
char
*
const
*
argv
)
{
do_args
(
argc
,
argv
);
loader_open_close
(
1
);
return
0
;
}
src/tests/loader-nproc-create.cc
0 → 100644
View file @
066d111c
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2010-2013 Tokutek Inc. All rights reserved."
#ident "$Id$"
#include "test.h"
#include <db.h>
#include <sys/resource.h>
static
int
loader_flags
=
0
;
static
const
char
*
envdir
=
TOKU_TEST_FILENAME
;
static
int
put_multiple_generate
(
DB
*
UU
(
dest_db
),
DB
*
UU
(
src_db
),
DBT_ARRAY
*
UU
(
dest_keys
),
DBT_ARRAY
*
UU
(
dest_vals
),
const
DBT
*
UU
(
src_key
),
const
DBT
*
UU
(
src_val
))
{
return
ENOMEM
;
}
static
void
loader_open_close
(
int
ndb
)
{
int
r
;
char
rmcmd
[
32
+
strlen
(
envdir
)];
snprintf
(
rmcmd
,
sizeof
rmcmd
,
"rm -rf %s"
,
envdir
);
r
=
system
(
rmcmd
);
CKERR
(
r
);
r
=
toku_os_mkdir
(
envdir
,
S_IRWXU
+
S_IRWXG
+
S_IRWXO
);
CKERR
(
r
);
DB_ENV
*
env
;
r
=
db_env_create
(
&
env
,
0
);
CKERR
(
r
);
r
=
env
->
set_generate_row_callback_for_put
(
env
,
put_multiple_generate
);
CKERR
(
r
);
int
envflags
=
DB_INIT_LOCK
|
DB_INIT_LOG
|
DB_INIT_MPOOL
|
DB_INIT_TXN
|
DB_CREATE
|
DB_PRIVATE
;
r
=
env
->
open
(
env
,
envdir
,
envflags
,
S_IRWXU
+
S_IRWXG
+
S_IRWXO
);
CKERR
(
r
);
env
->
set_errfile
(
env
,
stderr
);
DB
*
dbs
[
ndb
];
uint32_t
db_flags
[
ndb
];
uint32_t
dbt_flags
[
ndb
];
for
(
int
i
=
0
;
i
<
ndb
;
i
++
)
{
db_flags
[
i
]
=
DB_NOOVERWRITE
;
dbt_flags
[
i
]
=
0
;
r
=
db_create
(
&
dbs
[
i
],
env
,
0
);
CKERR
(
r
);
char
name
[
32
];
sprintf
(
name
,
"db%d"
,
i
);
r
=
dbs
[
i
]
->
open
(
dbs
[
i
],
NULL
,
name
,
NULL
,
DB_BTREE
,
DB_CREATE
,
0666
);
CKERR
(
r
);
}
DB_TXN
*
txn
;
r
=
env
->
txn_begin
(
env
,
NULL
,
&
txn
,
0
);
CKERR
(
r
);
struct
rlimit
current_nproc_limit
;
r
=
getrlimit
(
RLIMIT_NPROC
,
&
current_nproc_limit
);
assert
(
r
==
0
);
struct
rlimit
new_nproc_limit
=
current_nproc_limit
;
new_nproc_limit
.
rlim_cur
=
0
;
r
=
setrlimit
(
RLIMIT_NPROC
,
&
new_nproc_limit
);
assert
(
r
==
0
);
DB_LOADER
*
loader
;
int
loader_r
=
env
->
create_loader
(
env
,
txn
,
&
loader
,
ndb
>
0
?
dbs
[
0
]
:
NULL
,
ndb
,
dbs
,
db_flags
,
dbt_flags
,
loader_flags
);
r
=
setrlimit
(
RLIMIT_NPROC
,
&
current_nproc_limit
);
assert
(
r
==
0
);
if
(
loader_flags
&
LOADER_DISALLOW_PUTS
)
{
CKERR
(
loader_r
);
loader_r
=
loader
->
close
(
loader
);
CKERR
(
loader_r
);
}
else
{
CKERR2
(
loader_r
,
EAGAIN
);
}
r
=
txn
->
abort
(
txn
);
CKERR
(
r
);
for
(
int
i
=
0
;
i
<
ndb
;
i
++
)
{
r
=
dbs
[
i
]
->
close
(
dbs
[
i
],
0
);
CKERR
(
r
);
}
r
=
env
->
close
(
env
,
0
);
CKERR
(
r
);
}
static
void
do_args
(
int
argc
,
char
*
const
argv
[])
{
int
resultcode
;
char
*
cmd
=
argv
[
0
];
argc
--
;
argv
++
;
while
(
argc
>
0
)
{
if
(
strcmp
(
argv
[
0
],
"-h"
)
==
0
)
{
resultcode
=
0
;
do_usage:
fprintf
(
stderr
,
"Usage: %s -h -v -q -p
\n
"
,
cmd
);
exit
(
resultcode
);
}
else
if
(
strcmp
(
argv
[
0
],
"-v"
)
==
0
)
{
verbose
++
;
}
else
if
(
strcmp
(
argv
[
0
],
"-q"
)
==
0
)
{
verbose
--
;
if
(
verbose
<
0
)
verbose
=
0
;
}
else
if
(
strcmp
(
argv
[
0
],
"-p"
)
==
0
)
{
loader_flags
|=
LOADER_DISALLOW_PUTS
;
}
else
if
(
strcmp
(
argv
[
0
],
"-z"
)
==
0
)
{
loader_flags
|=
LOADER_COMPRESS_INTERMEDIATES
;
}
else
if
(
strcmp
(
argv
[
0
],
"-e"
)
==
0
)
{
argc
--
;
argv
++
;
if
(
argc
>
0
)
envdir
=
argv
[
0
];
}
else
{
fprintf
(
stderr
,
"Unknown arg: %s
\n
"
,
argv
[
0
]);
resultcode
=
1
;
goto
do_usage
;
}
argc
--
;
argv
++
;
}
}
int
test_main
(
int
argc
,
char
*
const
*
argv
)
{
do_args
(
argc
,
argv
);
loader_open_close
(
1
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment