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

Dynamic backends #705

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

abudnik
Copy link
Member

@abudnik abudnik commented May 29, 2016

Server parses config and starts backend, which was not presented in config initially, on DNET_BACKEND_ENABLE command. Thus, it is possible to add backends on the fly.

@shaitan
Copy link
Member

shaitan commented May 29, 2016

[13:06:15][Step 1/3] Set base directory: "/tmp/buildd/elliptics-2.26.11.0/obj-x86_64-linux-gnu/tests/result/dnet_backends_test"
[13:06:15][Step 1/3] Set cocaine run directory: "/tmp/elliptics-test-run-764d4862/"
[13:06:15][Step 1/3] Starting 5 servers
[13:06:15][Step 1/3] Starting server #1
[13:06:15][Step 1/3] Started server #1
[13:06:15][Step 1/3] *** glibc detected *** /tmp/buildd/elliptics-2.26.11.0/obj-x86_64-linux-gnu/tests/../example/dnet_ioserv: corrupted double-linked list: 0x000000000096e540 ***
[13:06:15][Step 1/3] ======= Backtrace: =========
[13:06:15][Step 1/3] /lib/x86_64-linux-gnu/libc.so.6(+0x7da26)[0x2ac4bc7d6a26]
[13:06:15][Step 1/3] /lib/x86_64-linux-gnu/libc.so.6(+0x7ed0b)[0x2ac4bc7d7d0b]
[13:06:15][Step 1/3] /tmp/buildd/elliptics-2.26.11.0/obj-x86_64-linux-gnu/tests/../library/libelliptics.so.2.26(_ZNSt6vectorI25dnet_backend_config_entrySaIS0_EE13_M_insert_auxIIS0_EEEvN9__gnu_cxx17__normal_iteratorIPS0_S2_EEDpOT_+0x397)[0x2ac4bc2279d7]
[13:06:15][Step 1/3] /tmp/buildd/elliptics-2.26.11.0/obj-x86_64-linux-gnu/tests/../library/libelliptics.so.2.26(_ZN17dnet_backend_info5parseEPN7ioremap9elliptics6config11config_dataERKNS2_6configE+0xca9)[0x2ac4bc21d129]
[13:06:15][Step 1/3] /tmp/buildd/elliptics-2.26.11.0/obj-x86_64-linux-gnu/tests/../library/libelliptics.so.2.26(dnet_backend_init+0x497)[0x2ac4bc21df87]
[13:06:15][Step 1/3] /tmp/buildd/elliptics-2.26.11.0/obj-x86_64-linux-gnu/tests/../library/libelliptics.so.2.26(dnet_cmd_backend_control+0x9a8)[0x2ac4bc21fd78]
[13:06:15][Step 1/3] /tmp/buildd/elliptics-2.26.11.0/obj-x86_64-linux-gnu/tests/../library/libelliptics.so.2.26(dnet_process_cmd_raw+0x1185)[0x2ac4bc20fea5]
[13:06:15][Step 1/3] /tmp/buildd/elliptics-2.26.11.0/obj-x86_64-linux-gnu/tests/../library/libelliptics_client.so.2.26(dnet_process_recv+0x7e0)[0x2ac4bbf27de0]
[13:06:15][Step 1/3] /tmp/buildd/elliptics-2.26.11.0/obj-x86_64-linux-gnu/tests/../library/libelliptics_client.so.2.26(dnet_io_process+0x5d1)[0x2ac4bbf522c1]
[13:06:15][Step 1/3] /lib/x86_64-linux-gnu/libpthread.so.0(+0x7e9a)[0x2ac4bc543e9a]
[13:06:15][Step 1/3] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x2ac4bc84c36d]

@@ -154,6 +159,7 @@ class config_data
config_data &operator() (const std::string &name, const variant &value);
const variant *value_impl(const std::string &name) const;

bool m_serializable;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add description to m_serializable and its getter/setter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@shaitan shaitan mentioned this pull request May 30, 2016
return std::shared_ptr<dnet_backend_info>();
}

void dnet_backend_info_manager::add_backend(std::shared_ptr<dnet_backend_info> &backend)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this does not leak one reference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

@bioothod
Copy link
Member

bioothod commented Jun 1, 2016

Please elaborate, what does this huge patch do? Why is this needed, what was the problem, why have you decided to 'fix' it this way?

@abudnik
Copy link
Member Author

abudnik commented Jun 1, 2016

why have you decided to 'fix' it this way?

backends array of dnet_backend_io structs in dnet_io was changed to array of pointers. It allows quick reallocating of the array for adding new backends on the fly, but introduces locking mechanics for every access to backends array via rw-lock.

For the same reasons backends vector in dnet_config_data was changed to a hash table encapsulated in dnet_backend_info_manager class.

@bioothod
Copy link
Member

bioothod commented Jun 9, 2016

There is definitely no quick reallocation, since you copy the whole array again and again when adding new elements.

Let's start with more fundamental questions: What is the purpose of this patch? What is the problem it tries to solve? Is it present in the list of issues to solve first which was introduced like a year ago?

@shaitan
Copy link
Member

shaitan commented Jun 9, 2016

This patch is the development of #661.

The issue behind these changes is: allow users to add/remove backends in dynamic without restarting dnet_ioserv.

These patch introduces minimal changes to solve the issue. The next step is refactoring dnet_io::backends and dnet_config_data::backends, and merging them into one entity that will rule all backends' life. We broke solution into 2 steps because "next step" will change a lot that can be dangerous. It will be done in a separate PR but not now.

@abudnik
Copy link
Member Author

abudnik commented Jun 9, 2016

There is definitely no quick reallocation, since you copy the whole array again and again when adding new elements.

Reallocation of small array of pointers is a pretty fast operation.

return 0;
}

struct dnet_backend_io *dnet_get_backend_io(struct dnet_io *io, size_t backend_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function doesn't increase reference counter or perform any other control flow operations (like remove object from array) else, why does it use locking?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants