Details
-
Bug
-
Resolution: Unresolved
-
Major
-
3.1.5, 4.1.1, 4.5.0, 5.0.0
-
None
-
Untriaged
-
No
Description
If couchstore encounters an invalid header while opening a file it will potentially rollback, find a valid header, continue along and report success. This could potentially result in dataloss without it being logged anywhere.
1
|
static couchstore_error_t find_header(Db *db, int64_t start_pos) |
2
|
{
|
3
|
couchstore_error_t last_header_errcode = COUCHSTORE_ERROR_NO_HEADER;
|
4
|
int64_t pos = start_pos;
|
5
|
pos -= pos % COUCH_BLOCK_SIZE;
|
6
|
for (; pos >= 0; pos -= COUCH_BLOCK_SIZE) { |
7
|
couchstore_error_t errcode = find_header_at_pos(db, pos);
|
8
|
switch(errcode) { |
9
|
case COUCHSTORE_SUCCESS: |
10
|
// Found it! |
11
|
return COUCHSTORE_SUCCESS; |
12
|
case COUCHSTORE_ERROR_NO_HEADER: |
13
|
// No header here, so keep going |
14
|
break; |
15
|
case COUCHSTORE_ERROR_ALLOC_FAIL: |
16
|
// Fatal error |
17
|
return errcode; |
18
|
default: |
19
|
// Invalid header; continue, but remember the last error |
20
|
last_header_errcode = errcode;
|
21
|
break; |
22
|
}
|
23
|
}
|
24
|
return last_header_errcode; |
25
|
}
|