Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jrse 2018 06 29 #165 #166

Merged
merged 4 commits into from
Jul 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ script:

- docker exec build sh -c 'rm -r /usr/local/var/mail/rbox'
- docker exec build sh -c 'cd /usr/local/bin; ./imaptest user=t%d pass=t port=10110 profile=/root/pop3-profile.conf users=100 clients=10 error_quit secs=150 output=/var/log/imaptest.log'

- docker exec build sh -c 'cd /usr/local/bin; ./imaptest user=t%d pass=t port=10143 users=100 clients=10 error_quit secs=60 copybox=INBOX.Drafts output=/var/log/imaptest.log'
- docker exec build bash -c '/usr/local/bin/exec.sh "cat /var/log/dovecot.log | grep \"Error:\""'
- docker exec build bash -c '/usr/local/bin/exec.sh "cat /var/log/dovecot.log | grep \"failed:\""'
- docker exec build bash -c '/usr/local/bin/exec.sh "cat /var/log/dovecot.log | grep \"Internal error\""'
Expand Down
18 changes: 18 additions & 0 deletions src/storage-rbox/rbox-copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@ static int rbox_mail_storage_try_copy(struct mail_save_context **_ctx, struct ma

ret_val = rados_storage->copy(src_oid, ns_src.c_str(), dest_oid, ns_dest.c_str(), metadata_update);
if (ret_val < 0) {
if (ret_val == -ENOENT) {
i_warning(
"copy mail failed: from namespace: %s to namespace %s: src_oid: %s, des_oid: %s, error_code: %d, "
"storage_pool: %s , most likely concurency issue",
ns_src.c_str(), ns_dest.c_str(), src_oid.c_str(), dest_oid.c_str(), ret_val,
rados_storage->get_pool_name().c_str());
rbox_mail_set_expunged(rmail);
return 0;
}
i_error(
"copy mail failed: from namespace: %s to namespace %s: src_oid: %s, des_oid: %s, error_code: %d, "
"storage_pool: %s",
Expand All @@ -222,6 +231,15 @@ static int rbox_mail_storage_try_copy(struct mail_save_context **_ctx, struct ma
bool delete_source = true;
ret_val = rados_storage->move(src_oid, ns_src.c_str(), dest_oid, ns_dest.c_str(), metadata_update, delete_source);
if (ret_val < 0) {
if (ret_val == -ENOENT) {
i_warning(
"move mail failed: from namespace: %s to namespace %s: src_oid: %s, des_oid: %s, error_code : %d, "
"pool_name: %s. most likely due to concurency issues",
ns_src.c_str(), ns_dest.c_str(), src_oid.c_str(), dest_oid.c_str(), ret_val,
rados_storage->get_pool_name().c_str());
rbox_mail_set_expunged(rmail);
return 0;
}
i_error(
"move mail failed: from namespace: %s to namespace %s: src_oid: %s, des_oid: %s, error_code : %d, "
"pool_name: %s",
Expand Down
1 change: 1 addition & 0 deletions src/storage-rbox/rbox-mail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ static int rbox_mail_metadata_get(struct rbox_mail *rmail, enum rbox_metadata_ke
if (ret == -ENOENT) {
i_warning("Errorcode: %d cannot get x_attr from object %s, process %d", ret,
rmail->mail_object->get_oid().c_str(), getpid());
rbox_mail_set_expunged(rmail);
} else {
i_error("Errorcode: %d cannot get x_attr from object %s, process %d", ret, rmail->mail_object->get_oid().c_str(),
getpid());
Expand Down
2 changes: 1 addition & 1 deletion src/storage-rbox/rbox-mail.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct rbox_mail {
librmb::RadosMailObject *mail_object;
uint32_t last_seq; // TODO(jrse): init with -1
};

extern void rbox_mail_set_expunged(struct rbox_mail *mail);
extern int rbox_get_index_record(struct mail *_mail);
extern struct mail *rbox_mail_alloc(struct mailbox_transaction_context *t, enum mail_fetch_field wanted_fields,
struct mailbox_header_lookup_ctx *wanted_headers);
Expand Down
4 changes: 2 additions & 2 deletions src/tests/storage-mock-rbox/test_storage_mock_rbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ TEST_F(StorageTest, mock_copy_failed_due_to_rados_err) {
EXPECT_CALL(*storage_mock_copy, wait_for_rados_operations(_)).Times(AtLeast(1)).WillRepeatedly(Return(false));

// TODO: EXPECT_CALL(*storage_mock_copy, set_metadata(_, _)).WillRepeatedly(Return(0));
EXPECT_CALL(*storage_mock_copy, copy(_, _, _, _, _)).WillRepeatedly(Return(-2));
EXPECT_CALL(*storage_mock_copy, copy(_, _, _, _, _)).WillRepeatedly(Return(-1));
EXPECT_CALL(*storage_mock_copy, get_io_ctx()).WillRepeatedly(ReturnRef(test_ioctx));

storage->s = storage_mock_copy;
Expand Down Expand Up @@ -517,6 +517,7 @@ TEST_F(StorageTest, mock_copy_failed_due_to_rados_err) {
mailbox_save_copy_flags(save_ctx, mail);

int ret2 = mailbox_copy(&save_ctx, mail);
// mail should be marked as expunged!!!
EXPECT_EQ(ret2, -1);

break; // only move one mail.
Expand All @@ -534,7 +535,6 @@ TEST_F(StorageTest, mock_copy_failed_due_to_rados_err) {

delete test_object;
delete test_object2;

}

TEST_F(StorageTest, copy_input_to_output_stream) {
Expand Down