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

Develop #370

Merged
merged 25 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
80969e4
Loglevel Debug is sufficient as it gets retried (#337)
jrse Jul 6, 2022
690127d
Bugfix/339 rados config timeout (#340)
jrse Aug 25, 2022
dde2fb3
Feature/342 object search (#343)
jrse Sep 22, 2022
30798cd
Bugfix/342 logging multithreading (#344)
jrse Sep 27, 2022
a58c735
Bugfix/rbox copy context (#347)
jrse Oct 20, 2022
09311f7
Merge branch 'master' into develop
jrse Oct 20, 2022
574fa4a
#364 and code cleanup
jrse Oct 27, 2022
1ef3f70
Merge branch 'master' into develop
jrse Oct 27, 2022
364e18d
Feature/349 ceph object index (#350)
jrse Nov 21, 2022
f0741a6
#349 bugfix return code doveadm rmb (#351)
jrse Nov 22, 2022
eb41db1
Merge branch 'master' into develop
jrse Nov 22, 2022
4efa9f1
#349 validate object (#353)
jrse Nov 26, 2022
8eac746
Merge branch 'master' into develop
jrse Nov 26, 2022
d2366a2
Bugfix/355 fix gzip trailer for empty stream (#357)
jrse Dec 5, 2022
8aa1297
Merge branch 'master' into develop
jrse Dec 5, 2022
3be0cff
#349 fix threshold calc for ceph index file
jrse Dec 5, 2022
0cbb2c0
#355 fix buffersize for write method 1 and 2 (#360)
jrse Dec 5, 2022
c05d89e
Merge branch 'master' into develop
jrse Dec 5, 2022
e6e6685
Bugfix 355 fix buffersize write method (#363)
jrse Dec 16, 2022
582f0a1
delete ceph index if doveadm mailbox delete -u <> INBOX
jrse Jan 26, 2023
32aa297
Fix/ceph index (#367)
jrse Jan 29, 2023
788cc32
Merge branch 'master' into develop
jrse Jan 29, 2023
012aac7
fix ceph-index-file-size calculation
jrse Feb 2, 2023
4ac7984
Merge branch 'master' into develop
jrse Feb 2, 2023
311335e
added unit test for object calculation
jrse Feb 2, 2023
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
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ jobs:
run: ./autogen.sh && ./configure --with-dovecot=/usr/local/lib/dovecot --enable-maintainer-mode --enable-debug --with-integration-tests --enable-valgrind --enable-debug
- name: build
run: make clean install
- name: tests
- name: test_storage_mock_rbox
run: valgrind src/tests/test_storage_mock_rbox_bugs
- name: test_utils
run: valgrind src/tests/test_librmb_utils
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## [0.0.50](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.50) (2023-02-02)
- fix: cleanup ceph-index size calculation

## [0.0.49](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.49) (2023-01-29)
- fix: cleanup ceph-index in case of mailbox INBOX delete

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
AC_PREREQ([2.59])


AC_INIT([dovecot-ceph-plugin], [0.0.49], [https://github.com/ceph-dovecot/dovecot-ceph-plugin/issues/new], ,[https://github.com/ceph-dovecot/dovecot-ceph-plugin])
AC_INIT([dovecot-ceph-plugin], [0.0.50], [https://github.com/ceph-dovecot/dovecot-ceph-plugin/issues/new], ,[https://github.com/ceph-dovecot/dovecot-ceph-plugin])


AC_CONFIG_AUX_DIR([.])
Expand Down
3 changes: 1 addition & 2 deletions rpm/dovecot-ceph-plugin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
Name: dovecot-ceph-plugin
Summary: Dovecot Ceph RADOS plugins

Version: 0.0.49

Version: 0.0.50

Release: 0%{?dist}
URL: https://github.com/ceph-dovecot/dovecot-ceph-plugin
Expand Down
10 changes: 10 additions & 0 deletions src/librmb/rados-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,14 @@ namespace librmb {
}
return index;
}

static double RadosUtils::object_size_percent(const double object_size, const double max_object_size) {
double ceph_index_size_percent = ( object_size / max_object_size ) * (double) 100.0;
return ceph_index_size_percent;
}

static bool RadosUtils::object_size_close_to_reach_max(const double object_size, const double max_object_size) {
return RadosUtils::object_size_percent(object_size, max_object_size) > 80;
}

} // namespace librmb
2 changes: 2 additions & 0 deletions src/librmb/rados-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ class RadosUtils {
static std::string convert_to_ceph_index(const std::string &str);

static std::set<std::string> ceph_index_to_set(const std::string &str);
static double object_size_percent(const double object_size, const double max_object_size);
static bool object_size_close_to_reach_max(const double object_size, const double max_object_size);
};

} // namespace librmb
Expand Down
14 changes: 7 additions & 7 deletions src/storage-rbox/rbox-save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,18 +653,18 @@ int rbox_save_finish(struct mail_save_context *_ctx) {
i_error("saved mail: %s failed. Metadata_count %ld, mail_size (%d)", r_ctx->rados_mail->get_oid()->c_str(),
r_ctx->rados_mail->get_metadata()->size(), r_ctx->rados_mail->get_mail_size());
}else{

if( r_storage->config->get_object_search_method() == 2){
// ceph config schalter an oder aus!
r_storage->s->ceph_index_append(*r_ctx->rados_mail->get_oid());
uint64_t index_size = r_storage->s->ceph_index_size();
double ceph_index_size_percent = ((double)index_size / (double)r_storage->s->get_max_object_size()) *(double)100.0;
// WARN if index reaches 80% of max object size
if( ceph_index_size_percent > 0.80) {
i_warning("ceph_index file(%d) close to exceed max_object size(%d), recalc index !", index_size, r_storage->s->get_max_object_size() );
r_storage->s->ceph_index_append(*r_ctx->rados_mail->get_oid());
if( librmb::RadosUtils::object_size_close_to_reach_max(
(double)r_storage->s->ceph_index_size(),
(double) r_storage->s->get_max_object_size())
) {
i_warning("ceph_index file(%d) close to exceed max_object size(%d) 80%, recalc index !", r_storage->s->ceph_index_size(), r_storage->s->get_max_object_size() );
}
}
}

if (r_storage->save_log->is_open()) {
r_storage->save_log->append(
librmb::RadosSaveLogEntry(*r_ctx->rados_mail->get_oid(), r_storage->s->get_namespace(),
Expand Down
86 changes: 25 additions & 61 deletions src/tests/librmb/test_librmb_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,57 +290,6 @@ __attribute__((noreturn)) static void *write_to_save_file(void *threadid) {

pthread_exit(NULL);
}
TEST(librmb, append_to_existing_file_multi_threading) {
std::string test_file_name = "test1.log";
int rc;
void *status;
pthread_attr_t attr;
pthread_t threads[5];
// Initialize and set thread joinable
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);

for (uintptr_t i = 0; i < 5; i++) {
rc = pthread_create(&threads[i], NULL, write_to_save_file, (void *)i);
}
sleep(1);
std::cout << " threads created " << std::endl;
// free attribute and wait for the other threads
pthread_attr_destroy(&attr);
for (int i = 0; i < 5; i++) {
rc = pthread_join(threads[i], &status);
if (rc) {
std::cout << "Error:unable to join," << rc << std::endl;
exit(-1);
}

std::cout << "Main: completed thread id :" << i;
std::cout << " exiting with status :" << status << std::endl;
}
sleep(1);
int line_count = 0;
/** check content **/
std::ifstream read(test_file_name);
while (true) {
librmb::RadosSaveLogEntry entry;
read >> entry;

if (read.eof()) {
break;
}
EXPECT_EQ(entry.oid, "abc");
EXPECT_EQ(entry.ns, "ns_1");
EXPECT_EQ(entry.pool, "mail_storage");
EXPECT_EQ(entry.op, "save");
line_count++;
}
EXPECT_EQ(25, line_count);
read.close();
std::remove(test_file_name.c_str());

std::cout << " exiting main " << std::endl;
// pthread_exit(NULL);
}

TEST(librmb, test_mvn_option) {
std::list<librmb::RadosMetadata *> metadata;
Expand Down Expand Up @@ -377,18 +326,33 @@ TEST(librmb, test_mvn_option) {
std::remove(test_file_name.c_str());
}

/*TEST(librmb, test_if) {
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
TEST(librmb, test_max_object_size_calculation) {

bool result = librmb::RadosUtils::object_size_close_to_reach_max(10.0,100.0);
EXPECT_EQ(result, false);

result = librmb::RadosUtils::object_size_close_to_reach_max(81.0,100.0);
EXPECT_EQ(result, true);

result = librmb::RadosUtils::object_size_close_to_reach_max(112820433.0
,134217728.0);
EXPECT_EQ(result, true);

result = librmb::RadosUtils::object_size_close_to_reach_max(13646193.0
,134217728.0);
EXPECT_EQ(result, false);

result = librmb::RadosUtils::object_size_close_to_reach_max(13646226.0
,134217728.0);
EXPECT_EQ(result, false);

result = librmb::RadosUtils::object_size_close_to_reach_max(13646259.0
,134217728.0);
EXPECT_EQ(result, false);

}

for (int i = 0; i < 10; ++i) {
std::cout << " value: " << arr[i] << std::endl;
}
for (int i = 0; i < 10; i++) {
std::cout << " value: " << arr[i] << std::endl;
}

EXPECT_EQ(1, 2);
}*/
TEST(librmb, mock_obj) {}
int main(int argc, char **argv) {
::testing::InitGoogleMock(&argc, argv);
Expand Down