reverbrain / elliptics

Distributed storage for medium and large objects with streaming support
http://reverbrain.com/elliptics
GNU Lesser General Public License v3.0
496 stars 85 forks source link

Dynamic backends #705

Open abudnik opened 8 years ago

abudnik commented 8 years ago

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 commented 8 years ago
[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]
bioothod commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

This patch is the development of https://github.com/reverbrain/elliptics/pull/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 commented 8 years ago

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.