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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
7d1992f4
Commit
7d1992f4
authored
May 15, 2014
by
Rich Prohaska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#239 fix dbremove crash when NOFILE limit is exceeded
parent
a003ebf1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
184 additions
and
1 deletion
+184
-1
src/tests/dbremove-nofile-limit.cc
src/tests/dbremove-nofile-limit.cc
+177
-0
src/ydb.cc
src/ydb.cc
+7
-1
No files found.
src/tests/dbremove-nofile-limit.cc
0 → 100644
View file @
7d1992f4
/* -*- 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) 2014 Tokutek Inc. All rights reserved."
#ident "$Id$"
// This test verifies that the env->dbremove function returns an error rather than
// crash when the NOFILE resource limit is exceeded.
#include "test.h"
#include <db.h>
#include <sys/resource.h>
static
const
char
*
envdir
=
TOKU_TEST_FILENAME
;
static
void
test_dbremove
()
{
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
);
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
*
db
;
r
=
db_create
(
&
db
,
env
,
0
);
CKERR
(
r
);
char
fname
[
32
];
sprintf
(
fname
,
"db%d"
,
0
);
r
=
db
->
open
(
db
,
nullptr
,
fname
,
nullptr
,
DB_BTREE
,
DB_CREATE
,
0666
);
CKERR
(
r
);
r
=
db
->
close
(
db
,
0
);
CKERR
(
r
);
DB_TXN
*
txn
;
r
=
env
->
txn_begin
(
env
,
nullptr
,
&
txn
,
0
);
CKERR
(
r
);
struct
rlimit
current_limit
;
r
=
getrlimit
(
RLIMIT_NOFILE
,
&
current_limit
);
assert
(
r
==
0
);
struct
rlimit
new_limit
=
current_limit
;
new_limit
.
rlim_cur
=
0
;
r
=
setrlimit
(
RLIMIT_NOFILE
,
&
new_limit
);
assert
(
r
==
0
);
r
=
env
->
dbremove
(
env
,
txn
,
fname
,
nullptr
,
0
);
CKERR2
(
r
,
EMFILE
);
r
=
setrlimit
(
RLIMIT_NOFILE
,
&
current_limit
);
assert
(
r
==
0
);
r
=
env
->
dbremove
(
env
,
txn
,
fname
,
nullptr
,
0
);
CKERR
(
r
);
r
=
txn
->
commit
(
txn
,
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
\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
{
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
);
test_dbremove
();
return
0
;
}
src/ydb.cc
View file @
7d1992f4
...
...
@@ -2807,7 +2807,13 @@ env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *dbname, u
r
=
toku_db_create
(
&
db
,
env
,
0
);
lazy_assert_zero
(
r
);
r
=
toku_db_open_iname
(
db
,
txn
,
iname
,
0
,
0
);
lazy_assert_zero
(
r
);
if
(
txn
&&
r
)
{
if
(
r
==
EMFILE
||
r
==
ENFILE
)
r
=
toku_ydb_do_error
(
env
,
r
,
"toku dbremove failed because open file limit reached
\n
"
);
else
r
=
toku_ydb_do_error
(
env
,
r
,
"toku dbremove failed
\n
"
);
goto
exit
;
}
if
(
txn
)
{
// Now that we have a writelock on dname, verify that there are still no handles open. (to prevent race conditions)
if
(
env_is_db_with_dname_open
(
env
,
dname
))
{
...
...
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