summaryrefslogtreecommitdiffstats
path: root/sbin/hastd/secondary.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r257155, r257582, r259191, r259192, r259193, r259194, r259195, r259196:trociny2013-12-281-5/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r257155: Make hastctl list command output current queue sizes. Reviewed by: pjd r257582 (pjd): Correct alignment. r259191: For memsync replication, hio_countdown is used not only as an indication when a request can be moved to done queue, but also for detecting the current state of memsync request. This approach has problems, e.g. leaking a request if memsynk ack from the secondary failed, or racy usage of write_complete, which should be called only once per write request, but for memsync can be entered by local_send_thread and ggate_send_thread simultaneously. So the following approach is implemented instead: 1) Use hio_countdown only for counting components we waiting to complete, i.e. initially it is always 2 for any replication mode. 2) To distinguish between "memsync ack" and "memsync fin" responses from the secondary, add and use hio_memsyncacked field. 3) write_complete() in component threads is called only before releasing hio_countdown (i.e. before the hio may be returned to the done queue). 4) Add and use hio_writecount refcounter to detect when write_complete() can be called in memsync case. Reported by: Pete French petefrench ingresso.co.uk Tested by: Pete French petefrench ingresso.co.uk r259192: Add some macros to make the code more readable (no functional chages). r259193: Fix compiler warnings. r259194: In remote_send_thread, if sending a request fails don't take the request back from the receive queue -- it might already be processed by remote_recv_thread, which lead to crashes like below: (primary) Unable to receive reply header: Connection reset by peer. (primary) Unable to send request (Connection reset by peer): WRITE(954662912, 131072). (primary) Disconnected from kopusha:7772. (primary) Increasing localcnt to 1. (primary) Assertion failed: (old > 0), function refcnt_release, file refcnt.h, line 62. Taking the request back was not necessary (it would properly be processed by the remote_recv_thread) and only complicated things. r259195: Send wakeup to threads waiting on empty queue before releasing the lock to decrease spurious wakeups. Submitted by: davidxu r259196: Check remote protocol version only for the first connection (when it is actually sent by the remote node). Otherwise it generated confusing "Negotiated protocol version 1" debug messages when processing the second connection.
* Fix comments.trociny2013-09-191-3/+2
| | | | | Approved by: re (marius) MFC after: 3 days
* Use cv_broadcast() instead of cv_signal() when waking up threadstrociny2013-09-191-1/+1
| | | | | | | | | | | | | | | | | | | | waiting on an empty queue as the queue may have several consumers. Before the fix the following scenario was possible: 2 threads are waiting on empty queue, 2 threads are inserting simultaneously. The first inserting thread detects that the queue is empty and is going to send the signal, but before it sends the second thread inserts too. When the first sends the signal only one of the waiting threads receive it while the other one may wait forever. The scenario above is is believed to be the cause of the observed cases, when ggate_recv_thread() was getting stuck on taking free request, while the free queue was not empty. Reviewed by: pjd Tested by: Yamagi Burmeister yamagi.org Approved by: re (marius) MFC after: 2 weeks
* Delete requests can be larger than MAXPHYS.pjd2013-03-141-1/+1
|
* Add i/o error counters to hastd(8) and make hastctl(8) displaytrociny2013-02-251-1/+17
| | | | | | | them. This may be useful for detecting problems with HAST disks. Discussed with and reviewed by: pjd MFC after: 1 week
* - Add support for 'memsync' mode. This is the fastest replication mode that'spjd2013-02-171-2/+46
| | | | | | | | | | why it will now be the default. - Bump protocol version to 2 and add backward compatibility for version 1. - Allow to specify hosts by kern.hostid as well (in addition to hostname and kern.hostuuid) in configuration file. Sponsored by: Panzura Tested by: trociny
* Style cleanups.pjd2012-01-131-6/+11
| | | | MFC after: 3 days
* For functions that return -1 on failure check exactly for -1 and not forpjd2012-01-101-16/+16
| | | | | | any negative number. MFC after: 3 days
* fork(2) returns -1 on failure, not some random negative number.pjd2012-01-061-1/+1
| | | | MFC after: 3 days
* Remove redundant assignment.pjd2011-12-151-2/+0
| | | | | Found by: Clang Static Analyzer MFC after: 1 week
* Remove redundant space.pjd2011-10-271-1/+1
| | | | MFC after: 3 days
* - Eliminate the need for hio_nv.pjd2011-10-271-25/+55
| | | | | | | - Introduce hio_clear() function for clearing hio before returning it onto free queue. MFC after: 3 days
* Correct comments.pjd2011-10-271-3/+3
| | | | MFC after: 3 days
* If the underlying provider doesn't support BIO_FLUSH, log it only oncepjd2011-09-281-4/+14
| | | | | | and don't bother trying in the future. MFC after: 3 days
* Break a bit earlier.pjd2011-09-281-0/+1
| | | | MFC after: 3 days
* Prefer PJDLOG_ASSERT() and PJDLOG_ABORT() over assert() and abort().pjd2011-09-271-2/+2
| | | | | | | pjdlog versions will log problem to syslog when application is running in background. MFC after: 3 days
* In HAST we use two sockets - one for only sending the data and one fortrociny2011-06-171-0/+4
| | | | | | | | | | | | | | | | | | only receiving the data. In r220271 the unused directions were disabled using shutdown(2). Unfortunately, this broke automatic receive buffer sizing, which currently works only for connections in ETASBLISHED state. It was a root cause of the issue reported by users, when connection between primary and secondary could get stuck. Disable the code introduced in r220271 until the issue with automatic buffer sizing is not resolved. Reported by: Daniel Kalchev <daniel@digsys.bg>, danger, sobomax Tested by: Daniel Kalchev <daniel@digsys.bg>, danger Approved by: pjd (mentor) MFC after: 1 week
* Keep statistics on number of BIO_READ, BIO_WRITE, BIO_DELETE and BIO_FLUSHpjd2011-05-231-0/+14
| | | | | | | | | | | requests as well as number of activemap updates. Number of BIO_WRITEs and activemap updates are especially interesting, because if those two are too close to each other, it means that your workload needs bigger number of dirty extents. Activemap should be updated as rarely as possible. MFC after: 1 week
* Recognize HIO_FLUSH requests.pjd2011-05-211-0/+1
| | | | MFC after: 1 week
* Currently we are unable to use capsicum for the primary worker process,pjd2011-05-141-1/+1
| | | | | | | | | | | | | | | | | because we need to do ioctl(2)s, which are not permitted in the capability mode. What we do now is to chroot(2) to /var/empty, which restricts access to file system name space and we drop privileges to hast user and hast group. This still allows to access to other name spaces, like list of processes, network and sysvipc. To address that, use jail(2) instead of chroot(2). Using jail(2) will restrict access to process table, network (we use ip-less jails) and sysvipc (if security.jail.sysvipc_allowed is turned off). This provides much better separation. MFC after: 1 week
* Scenario:pjd2011-04-191-0/+1
| | | | | | | | | | | | | | | | | | | - We have two nodes connected and synchronized (local counters on both sides are 0). - We take secondary down and recreate it. - Primary connects to it and starts synchronization (but local counters are still 0). - We switch the roles. - Synchronization restarts but data is synchronized now from new primary (because local counters are 0) that doesn't have new data yet. This fix this issue we bump local counter on primary when we discover that connected secondary was recreated and has no data yet. Reported by: trociny Discussed with: trociny Tested by: trociny MFC after: 1 week
* Declare directions for sockets between primary and secondary.pjd2011-04-021-0/+7
| | | | | | | In HAST we use two sockets - one for only sending the data and one for only receiving the data. MFC after: 1 month
* Add mapsize to the header just before sending the packet.pjd2011-03-251-1/+1
| | | | | | | | | Before it could change later and we were sending invalid mapsize. Some time ago I added optimization where when nodes are connected for the first time and there were no writes to them yet, there is no initial full synchronization. This bug prevented it from working. MFC after: 1 week
* Use role2str() when setting process title.pjd2011-03-251-1/+1
| | | | MFC after: 1 week
* Don't create socketpair for connection forwarding between parent and secondary.pjd2011-03-231-12/+0
| | | | | | Secondary doesn't need to connect anywhere. MFC after: 1 week
* White space cleanups.pjd2011-03-221-2/+2
| | | | MFC after: 1 week
* When dropping privileges prefer capsicum over chroot+setgid+setuid.pjd2011-03-211-1/+1
| | | | | | | | | We can use capsicum for secondary worker processes and hastctl. When working as primary we drop privileges using chroot+setgid+setuid still as we need to send ioctl(2)s to ggate device, for which capsicum doesn't allow (yet). X-MFC after: capsicum is merged to stable/8
* Fix typo.pjd2011-03-211-1/+1
| | | | MFC after: 1 week
* Be pedantic and free nvout before exiting.pjd2011-03-211-0/+1
| | | | MFC after: 1 week
* Detect situation where resource internal identifier differs.pjd2011-03-211-0/+13
| | | | | | | This means that both nodes have separately managed resources that don't have the same data. MFC after: 1 week
* In hast.conf we define the other node's address in 'remote' variable.pjd2011-03-211-3/+3
| | | | | | | | | | | | | | | | | | This way we know how to connect to secondary node when we are primary. The same variable is used by the secondary node - it only accepts connections from the address stored in 'remote' variable. In cluster configurations it is common that each node has its individual IP address and there is one addtional shared IP address which is assigned to primary node. It seems it is possible that if the shared IP address is from the same network as the individual IP address it might be choosen by the kernel as a source address for connection with the secondary node. Such connection will be rejected by secondary, as it doesn't come from primary node individual IP. Add 'source' variable that allows to specify source IP address we want to bind to before connecting to the secondary node. MFC after: 1 week
* For secondary, set 2 * HAST_KEEPALIVE seconds timeout for incomingtrociny2011-03-171-1/+1
| | | | | | | | | | connection so the worker will exit if it does not receive packets from the primary during this interval. Reported by: Christian Vogt <Christian.Vogt@haw-hamburg.de> Tested by: Christian Vogt <Christian.Vogt@haw-hamburg.de> Approved by: pjd (mentor) MFC after: 1 week
* Make workers inherit debug level from the main process.trociny2011-03-111-1/+3
| | | | | Approved by: pjd (mentor) MFC after: 1 week
* Setup another socketpair between parent and child, so that primary sandboxedpjd2011-02-031-0/+12
| | | | | | | | | worker can ask the main privileged process to connect in worker's behalf and then we can migrate descriptor using this socketpair to worker. This is not really needed now, but will be needed once we start to use capsicum for sandboxing. MFC after: 1 week
* Let the caller log info about successful privilege drop.pjd2011-02-031-0/+1
| | | | | | We don't want to log this in hastctl. MFC after: 1 week
* - Use pjdlog for assertions and aborts as this will log assert/abort messagepjd2011-01-311-7/+6
| | | | | | | | | to syslog if we run in background. - Asserts in proto.c that method we want to call is implemented and remove dummy methods from protocols implementation that are only there to abort the program with nice message. MFC after: 1 week
* Drop privileges in worker processes.pjd2011-01-281-0/+3
| | | | | | | | | Accepting connections and handshaking in secondary is still done before dropping privileges. It should be implemented by only accepting connections in privileged main process and passing connection descriptors to the worker, but is not implemented yet. MFC after: 1 week
* Use newly added descriptors_assert() function to ensure only expectedpjd2011-01-281-0/+2
| | | | | | descriptors are open. MFC after: 1 week
* Close all unneeded descriptors after fork(2).pjd2011-01-281-6/+11
| | | | MFC after: 1 week
* Before this change on first connect between primary and secondary wepjd2010-10-241-2/+11
| | | | | | | | | | | | | initialize all the data. This is huge waste of time and resources if there were no writes yet, as there is no real data to synchronize. Optimize this by sending "virgin" argument to secondary, which gives it a hint that synchronization is not needed. In the common case (where noth nodes are configured at the same time) instead of synchronizing everything, we don't synchronize at all. MFC after: 1 week
* Simplify code a bit.pjd2010-10-241-3/+1
| | | | MFC after: 3 days
* Plug memory leak.pjd2010-10-241-0/+2
| | | | MFC after: 3 days
* Switch to sigprocmask(2) API also in the main process and secondary process.pjd2010-09-221-2/+4
| | | | | | | | | This way the primary process inherits signal mask from the main process, which fixes a race where signal is delivered to the primary process before configuring signal mask. Reported by: Mikolaj Golub <to.my.trociny@gmail.com> MFC after: 3 days
* Fix possible deadlock where worker process sends an event to the main processpjd2010-09-221-4/+14
| | | | | | | | | | | while the main process sends control message to the worker process, but worker process hasn't started control thread yet, because it waits for reply from the main process. The fix is to start the control thread before sending any events. Reported and fix suggested by: Mikolaj Golub <to.my.trociny@gmail.com> MFC after: 3 days
* Add __dead2 to functions that we know they are going to exit.pjd2010-09-201-1/+1
| | | | MFC after: 3 days
* Correct error message.pjd2010-08-311-1/+1
| | | | | Submitted by: Mikolaj Golub <to.my.trociny@gmail.com> MFC after: 2 weeks
* Because it is very hard to make fork(2) from threaded process safe (we arepjd2010-08-301-4/+17
| | | | | | | | | | | | | | limited to async-signal safe functions in the child process), move all hooks execution to the main (non-threaded) process. Do it by maintaining connection (socketpair) between child and parent and sending events from the child to parent, so it can execute the hook. This is step in right direction for others reasons too. For example there is one less problem to drop privs in worker processes. MFC after: 2 weeks Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com
* Execute hook when connection between the nodes is established or lost.pjd2010-08-301-3/+21
| | | | | MFC after: 2 weeks Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com
* Execute hook when split-brain is detected.pjd2010-08-301-0/+2
| | | | | MFC after: 2 weeks Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com
* Allow to run hooks from the main hastd process.pjd2010-08-291-0/+3
| | | | | MFC after: 2 weeks Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com
OpenPOWER on IntegriCloud