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
e20411dd
Commit
e20411dd
authored
Apr 16, 2013
by
Dave Wells
Committed by
Yoni Fogel
Apr 16, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
assert labeling 2
git-svn-id:
file:///svn/toku/tokudb@20289
c7de825b-a66e-492c-adef-691d508d4ae1
parent
23e3cd6b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
39 deletions
+39
-39
newbrt/brtloader.c
newbrt/brtloader.c
+39
-39
No files found.
newbrt/brtloader.c
View file @
e20411dd
...
...
@@ -146,11 +146,11 @@ void brtloader_fi_destroy (struct file_infos *fi, BOOL is_error)
}
for
(
int
i
=
0
;
i
<
fi
->
n_files
;
i
++
)
{
if
(
fi
->
file_infos
[
i
].
is_open
)
{
asser
t
(
is_error
);
invarian
t
(
is_error
);
fclose
(
fi
->
file_infos
[
i
].
file
);
// don't check for errors, since we are in an error case.
}
if
(
fi
->
file_infos
[
i
].
is_extant
)
{
asser
t
(
is_error
);
invarian
t
(
is_error
);
unlink
(
fi
->
file_infos
[
i
].
fname
);
toku_free
(
fi
->
file_infos
[
i
].
fname
);
}
...
...
@@ -173,7 +173,7 @@ static int open_file_add (struct file_infos *fi,
fi
->
n_files_limit
*=
2
;
XREALLOC_N
(
fi
->
n_files_limit
,
fi
->
file_infos
);
}
asser
t
(
fi
->
n_files
<
fi
->
n_files_limit
);
invarian
t
(
fi
->
n_files
<
fi
->
n_files_limit
);
fi
->
file_infos
[
fi
->
n_files
].
is_open
=
TRUE
;
fi
->
file_infos
[
fi
->
n_files
].
is_extant
=
TRUE
;
fi
->
file_infos
[
fi
->
n_files
].
fname
=
fname
;
...
...
@@ -196,9 +196,9 @@ int brtloader_fi_reopen (struct file_infos *fi, FIDX idx, const char *mode) {
int
result
=
0
;
int
r
=
toku_pthread_mutex_lock
(
&
fi
->
lock
);
resource_assert
(
r
==
0
);
int
i
=
idx
.
idx
;
asser
t
(
i
>=
0
&&
i
<
fi
->
n_files
);
asser
t
(
!
fi
->
file_infos
[
i
].
is_open
);
asser
t
(
fi
->
file_infos
[
i
].
is_extant
);
invarian
t
(
i
>=
0
&&
i
<
fi
->
n_files
);
invarian
t
(
!
fi
->
file_infos
[
i
].
is_open
);
invarian
t
(
fi
->
file_infos
[
i
].
is_extant
);
fi
->
file_infos
[
i
].
file
=
fopen
(
fi
->
file_infos
[
i
].
fname
,
mode
);
if
(
fi
->
file_infos
[
i
].
file
==
NULL
)
{
result
=
errno
;
goto
error
;
}
fi
->
file_infos
[
i
].
is_open
=
TRUE
;
...
...
@@ -213,10 +213,10 @@ int brtloader_fi_reopen (struct file_infos *fi, FIDX idx, const char *mode) {
int
brtloader_fi_close
(
struct
file_infos
*
fi
,
FIDX
idx
)
{
{
int
r2
=
toku_pthread_mutex_lock
(
&
fi
->
lock
);
resource_assert
(
r2
==
0
);
}
asser
t
(
fi
->
n_files_open
>
0
);
invarian
t
(
fi
->
n_files_open
>
0
);
fi
->
n_files_open
--
;
asser
t
(
idx
.
idx
>=
0
&&
idx
.
idx
<
fi
->
n_files
);
asser
t
(
fi
->
file_infos
[
idx
.
idx
].
is_open
);
invarian
t
(
idx
.
idx
>=
0
&&
idx
.
idx
<
fi
->
n_files
);
invarian
t
(
fi
->
file_infos
[
idx
.
idx
].
is_open
);
fi
->
file_infos
[
idx
.
idx
].
is_open
=
FALSE
;
int
r
=
fclose
(
fi
->
file_infos
[
idx
.
idx
].
file
);
{
int
r2
=
toku_pthread_mutex_unlock
(
&
fi
->
lock
);
resource_assert
(
r2
==
0
);
}
...
...
@@ -226,12 +226,12 @@ int brtloader_fi_close (struct file_infos *fi, FIDX idx)
int
brtloader_fi_unlink
(
struct
file_infos
*
fi
,
FIDX
idx
)
{
{
int
r2
=
toku_pthread_mutex_lock
(
&
fi
->
lock
);
resource_assert
(
r2
==
0
);
}
asser
t
(
fi
->
n_files_extant
>
0
);
invarian
t
(
fi
->
n_files_extant
>
0
);
fi
->
n_files_extant
--
;
int
id
=
idx
.
idx
;
asser
t
(
id
>=
0
&&
id
<
fi
->
n_files
);
asser
t
(
!
fi
->
file_infos
[
id
].
is_open
);
// must be closed before we unlink
asser
t
(
fi
->
file_infos
[
id
].
is_extant
);
// must still exist
invarian
t
(
id
>=
0
&&
id
<
fi
->
n_files
);
invarian
t
(
!
fi
->
file_infos
[
id
].
is_open
);
// must be closed before we unlink
invarian
t
(
fi
->
file_infos
[
id
].
is_extant
);
// must still exist
fi
->
file_infos
[
id
].
is_extant
=
FALSE
;
int
r
=
unlink
(
fi
->
file_infos
[
id
].
fname
);
if
(
r
!=
0
)
r
=
errno
;
toku_free
(
fi
->
file_infos
[
id
].
fname
);
...
...
@@ -418,8 +418,8 @@ static void brt_loader_set_panic(BRTLOADER bl, int error) {
// One of the tests uses this.
FILE
*
toku_bl_fidx2file
(
BRTLOADER
bl
,
FIDX
i
)
{
{
int
r2
=
toku_pthread_mutex_lock
(
&
bl
->
file_infos
.
lock
);
resource_assert
(
r2
==
0
);
}
asser
t
(
i
.
idx
>=
0
&&
i
.
idx
<
bl
->
file_infos
.
n_files
);
asser
t
(
bl
->
file_infos
.
file_infos
[
i
.
idx
].
is_open
);
invarian
t
(
i
.
idx
>=
0
&&
i
.
idx
<
bl
->
file_infos
.
n_files
);
invarian
t
(
bl
->
file_infos
.
file_infos
[
i
.
idx
].
is_open
);
FILE
*
result
=
bl
->
file_infos
.
file_infos
[
i
.
idx
].
file
;
{
int
r2
=
toku_pthread_mutex_unlock
(
&
bl
->
file_infos
.
lock
);
resource_assert
(
r2
==
0
);
}
return
result
;
...
...
@@ -724,7 +724,7 @@ static void* extractor_thread (void *blv) {
int
rq
=
queue_deq
(
bl
->
primary_rowset_queue
,
&
item
,
NULL
,
NULL
);
BL_TRACE
(
blt_extract_deq
);
if
(
rq
==
EOF
)
break
;
asser
t
(
rq
==
0
);
// other errors are arbitrarily bad.
invarian
t
(
rq
==
0
);
// other errors are arbitrarily bad.
}
struct
rowset
*
primary_rowset
=
(
struct
rowset
*
)
item
;
...
...
@@ -1436,7 +1436,7 @@ static int merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE
if
(
n_rows_done
%
rows_per_report
==
0
)
{
// need to update the progress.
double
fraction_of_remaining_we_just_did
=
(
double
)
rows_per_report
/
(
double
)(
n_rows
-
n_rows_done
+
rows_per_report
);
asser
t
(
0
<=
fraction_of_remaining_we_just_did
&&
fraction_of_remaining_we_just_did
<=
1
);
invarian
t
(
0
<=
fraction_of_remaining_we_just_did
&&
fraction_of_remaining_we_just_did
<=
1
);
int
progress_just_done
=
fraction_of_remaining_we_just_did
*
progress_allocation
;
progress_allocation
-=
progress_just_done
;
r
=
update_progress
(
progress_just_done
,
bl
,
"in file merge"
);
...
...
@@ -1696,7 +1696,7 @@ static inline void dbout_init(struct dbout *out) {
}
static
inline
void
dbout_destroy
(
struct
dbout
*
out
)
{
asser
t
(
out
->
fd
==
-
1
);
invarian
t
(
out
->
fd
==
-
1
);
toku_free
(
out
->
translation
);
out
->
translation
=
NULL
;
}
...
...
@@ -1726,10 +1726,10 @@ static void seek_align_locked(struct dbout *out) {
if
(
r
!=
out
->
current_off
)
{
fprintf
(
stderr
,
"Seek failed %s (errno=%d)
\n
"
,
strerror
(
errno
),
errno
);
}
asser
t
(
r
==
out
->
current_off
);
asser
t
(
out
->
current_off
>=
old_current_off
);
asser
t
(
out
->
current_off
<
old_current_off
+
alignment
);
asser
t
(
out
->
current_off
%
alignment
==
0
);
invarian
t
(
r
==
out
->
current_off
);
invarian
t
(
out
->
current_off
>=
old_current_off
);
invarian
t
(
out
->
current_off
<
old_current_off
+
alignment
);
invarian
t
(
out
->
current_off
%
alignment
==
0
);
}
static
void
seek_align
(
struct
dbout
*
out
)
{
...
...
@@ -1824,7 +1824,7 @@ static inline long int loader_random(void) {
}
static
struct
leaf_buf
*
start_leaf
(
struct
dbout
*
out
,
const
struct
descriptor
*
desc
,
int64_t
lblocknum
)
{
asser
t
(
lblocknum
<
out
->
n_translations_limit
);
invarian
t
(
lblocknum
<
out
->
n_translations_limit
);
struct
leaf_buf
*
MALLOC
(
lbuf
);
assert
(
lbuf
);
lbuf
->
blocknum
=
lblocknum
;
...
...
@@ -1936,8 +1936,8 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl,
}
out
.
translation
[
0
].
off
=
-
2LL
;
out
.
translation
[
0
].
size
=
0
;
// block 0 is NULL
asser
t
(
1
==
RESERVED_BLOCKNUM_TRANSLATION
);
asser
t
(
2
==
RESERVED_BLOCKNUM_DESCRIPTOR
);
invarian
t
(
1
==
RESERVED_BLOCKNUM_TRANSLATION
);
invarian
t
(
2
==
RESERVED_BLOCKNUM_DESCRIPTOR
);
out
.
translation
[
1
].
off
=
-
1
;
// block 1 is the block translation, filled in later
out
.
translation
[
2
].
off
=
-
1
;
// block 2 is the descriptor
seek_align
(
&
out
);
...
...
@@ -2034,11 +2034,11 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl,
// write the descriptor
{
seek_align
(
&
out
);
asser
t
(
out
.
n_translations
>=
RESERVED_BLOCKNUM_DESCRIPTOR
);
asser
t
(
out
.
translation
[
RESERVED_BLOCKNUM_DESCRIPTOR
].
off
==
-
1
);
invarian
t
(
out
.
n_translations
>=
RESERVED_BLOCKNUM_DESCRIPTOR
);
invarian
t
(
out
.
translation
[
RESERVED_BLOCKNUM_DESCRIPTOR
].
off
==
-
1
);
out
.
translation
[
RESERVED_BLOCKNUM_DESCRIPTOR
].
off
=
out
.
current_off
;
size_t
desc_size
=
4
+
toku_serialize_descriptor_size
(
descriptor
);
asser
t
(
desc_size
>
0
);
invarian
t
(
desc_size
>
0
);
out
.
translation
[
RESERVED_BLOCKNUM_DESCRIPTOR
].
size
=
desc_size
;
struct
wbuf
wbuf
;
char
*
MALLOC_N
(
desc_size
,
buf
);
...
...
@@ -2136,7 +2136,7 @@ static int loader_do_i (BRTLOADER bl,
//printf("doing i use %d progress=%d fin at %d\n", progress_allocation, bl->progress, bl->progress+progress_allocation);
struct
merge_fileset
*
fs
=
&
(
bl
->
fs
[
which_db
]);
struct
rowset
*
rows
=
&
(
bl
->
rows
[
which_db
]);
asser
t
(
rows
->
data
==
NULL
);
// the rows should be all cleaned up already
invarian
t
(
rows
->
data
==
NULL
);
// the rows should be all cleaned up already
// a better allocation would be to figure out roughly how many merge passes we'll need.
int
allocation_for_merge
=
(
2
*
progress_allocation
)
/
3
;
...
...
@@ -2225,9 +2225,9 @@ static int toku_brt_loader_close_internal (BRTLOADER bl)
result
=
update_progress
(
0
,
bl
,
"did index"
);
if
(
result
)
goto
error
;
}
asser
t
(
bl
->
file_infos
.
n_files_open
==
0
);
asser
t
(
bl
->
file_infos
.
n_files_extant
==
0
);
asser
t
(
bl
->
progress
==
PROGRESS_MAX
);
invarian
t
(
bl
->
file_infos
.
n_files_open
==
0
);
invarian
t
(
bl
->
file_infos
.
n_files_extant
==
0
);
invarian
t
(
bl
->
progress
==
PROGRESS_MAX
);
error:
brtloader_destroy
(
bl
,
(
BOOL
)(
result
!=
0
));
BL_TRACE
(
blt_close
);
...
...
@@ -2251,7 +2251,7 @@ int toku_brt_loader_close (BRTLOADER bl,
if
(
bl
->
extractor_live
)
{
r
=
finish_extractor
(
bl
);
lazy_assert
(
r
==
0
);
// LAZY !!! should check this error code and cleanup if needed.
assert
(
!
bl
->
extractor_live
);
lazy_
assert
(
!
bl
->
extractor_live
);
}
// check for an error during extraction
...
...
@@ -2318,7 +2318,7 @@ static void add_pair_to_leafnode (struct leaf_buf *lbuf, unsigned char *key, int
putbuf_bytes
(
&
lbuf
->
dbuf
,
key
,
keylen
);
putbuf_bytes
(
&
lbuf
->
dbuf
,
val
,
vallen
);
int
le_len
=
1
+
4
+
4
+
keylen
+
vallen
;
asser
t
(
le_off
+
le_len
==
lbuf
->
dbuf
.
off
);
invarian
t
(
le_off
+
le_len
==
lbuf
->
dbuf
.
off
);
u_int32_t
this_x
=
x1764_memory
(
lbuf
->
dbuf
.
buf
+
le_off
,
le_len
);
u_int32_t
this_prod
=
lbuf
->
rand4fingerprint
*
this_x
;
lbuf
->
local_fingerprint
+=
this_prod
;
...
...
@@ -2331,7 +2331,7 @@ static void add_pair_to_leafnode (struct leaf_buf *lbuf, unsigned char *key, int
}
static
int
write_literal
(
struct
dbout
*
out
,
void
*
data
,
size_t
len
)
{
asser
t
(
out
->
current_off
%
4096
==
0
);
invarian
t
(
out
->
current_off
%
4096
==
0
);
int
result
=
toku_os_write
(
out
->
fd
,
data
,
len
);
if
(
result
==
0
)
out
->
current_off
+=
len
;
...
...
@@ -2470,7 +2470,7 @@ static int write_translation_table (struct dbout *out, long long *off_of_transla
}
unsigned
int
checksum
=
x1764_memory
(
ttable
.
buf
,
ttable
.
off
);
putbuf_int32
(
&
ttable
,
checksum
);
asser
t
(
bt_size_on_disk
==
ttable
.
off
);
invarian
t
(
bt_size_on_disk
==
ttable
.
off
);
int
result
=
toku_os_pwrite
(
out
->
fd
,
ttable
.
buf
,
ttable
.
off
,
off_of_translation
);
dbuf_destroy
(
&
ttable
);
*
off_of_translation_p
=
off_of_translation
;
...
...
@@ -2610,7 +2610,7 @@ static void write_nonleaf_node (BRTLOADER bl, struct dbout *out, int64_t blocknu
DBT
*
pivots
,
/* must free this array, as well as the things it points t */
struct
subtree_info
*
subtree_info
,
int
height
,
const
struct
descriptor
*
desc
)
{
asser
t
(
height
>
0
);
invarian
t
(
height
>
0
);
int
result
=
0
;
...
...
@@ -2706,7 +2706,7 @@ static int write_nonleaves (BRTLOADER bl, FIDX pivots_fidx, struct dbout *out, s
// 3) We put the 16th pivot into the next pivots file.
{
int
r
=
fseek
(
toku_bl_fidx2file
(
bl
,
pivots_fidx
),
0
,
SEEK_SET
);
if
(
r
!=
0
)
{
asser
t
(
errno
!=
0
);
return
errno
;
}
if
(
r
!=
0
)
{
invarian
t
(
errno
!=
0
);
return
errno
;
}
}
FIDX
next_pivots_file
;
...
...
@@ -2784,7 +2784,7 @@ static int write_nonleaves (BRTLOADER bl, FIDX pivots_fidx, struct dbout *out, s
}
}
if
(
result
==
0
)
asser
t
(
n_subtrees_used
==
sts
->
n_subtrees
);
invarian
t
(
n_subtrees_used
==
sts
->
n_subtrees
);
cilk_sync
;
...
...
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