mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 02:48:08 +01:00
e0b22c139c
The retries are hardcoded to a small number, and error handling aborts than propagating errors from notmuch_database_reopen. These are both somewhat justified by the assumption that most things that can go wrong in Xapian::Database::reopen are rare and fatal. Here's the brief discussion with Xapian upstream: 24-02-2017 08:12:57 < bremner> any intuition about how likely Xapian::Database::reopen is to fail? I'm catching a DatabaseModifiedError somewhere where handling any further errors is tricky, and wondering about treating a failed reopen as as "the impossible happened, stopping" 24-02-2017 16:22:34 < olly> bremner: there should not be much scope for failure - stuff like out of memory or disk errors, which are probably a good enough excuse to stop
66 lines
1.7 KiB
Bash
Executable file
66 lines
1.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
test_description="DatabaseModifiedError handling"
|
|
. ./test-lib.sh || exit 1
|
|
|
|
# add enough messages to trigger the exception
|
|
add_email_corpus
|
|
|
|
test_begin_subtest "catching DatabaseModifiedError in _notmuch_message_ensure_metadata"
|
|
# it seems to need to be an early document to trigger the exception
|
|
first_id=$(notmuch search --output=messages '*'| head -1 | sed s/^id://)
|
|
|
|
test_C ${MAIL_DIR} <<EOF
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <notmuch-test.h>
|
|
#include <talloc.h>
|
|
#include <assert.h>
|
|
int
|
|
main (int argc, char **argv)
|
|
{
|
|
const char *path = argv[1];
|
|
|
|
notmuch_database_t *rw_db, *ro_db;
|
|
notmuch_messages_t *messages;
|
|
notmuch_message_t *message, *ro_message;
|
|
notmuch_query_t *query;
|
|
notmuch_tags_t *tags;
|
|
|
|
EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_ONLY, &ro_db));
|
|
assert(ro_db);
|
|
|
|
EXPECT0 (notmuch_database_find_message (ro_db, "${first_id}", &ro_message));
|
|
assert(ro_message);
|
|
|
|
EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &rw_db));
|
|
query = notmuch_query_create(rw_db, "");
|
|
EXPECT0 (notmuch_query_search_messages_st (query, &messages));
|
|
|
|
for (int count=0;
|
|
notmuch_messages_valid (messages);
|
|
notmuch_messages_move_to_next (messages), count++) {
|
|
message = notmuch_messages_get (messages);
|
|
for (int i=0; i<200; i++) {
|
|
char *tag_str = talloc_asprintf(rw_db, "%d", i);
|
|
EXPECT0 (notmuch_message_add_tag (message, tag_str));
|
|
talloc_free (tag_str);
|
|
}
|
|
}
|
|
|
|
notmuch_database_close (rw_db);
|
|
|
|
tags = notmuch_message_get_tags (ro_message);
|
|
if (tags)
|
|
printf("SUCCESS\n");
|
|
return 0;
|
|
}
|
|
EOF
|
|
|
|
cat <<'EOF' >EXPECTED
|
|
== stdout ==
|
|
SUCCESS
|
|
== stderr ==
|
|
EOF
|
|
test_expect_equal_file EXPECTED OUTPUT
|
|
|
|
test_done
|