summaryrefslogtreecommitdiff
path: root/ctdb
Commit message (Collapse)AuthorAgeFilesLines
* ctdb-daemon: Make node inactive in the NODE_STOP controlMartin Schwenke2019-08-201-0/+2
| | | | | | | | | | | | | | | | | | | Currently some of this is supported by a periodic check in the recovery daemon's main_loop(), which notices the flag change, sets recovery mode active and freezes databases. If STOP_NODE returns immediately then the associated recovery can complete and the node can be continued before databases are actually frozen. Instead, immediately do all of the things that make a node inactive. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14087 RN: Stop "ctdb stop" from completing before freezing databases Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Tue Aug 20 08:32:27 UTC 2019 on sn-devel-184
* ctdb-daemon: Drop unused function ctdb_local_node_got_banned()Martin Schwenke2019-08-202-25/+0
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14087 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-daemon: Switch banning code to use ctdb_node_become_inactive()Martin Schwenke2019-08-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | There's no reason to avoid immediately setting recovery mode to active and initiating freeze of databases. This effectively reverts the following commits: d8f3b490bbb691c9916eed0df5b980c1aef23c85 b4357a79d916b1f8ade8fa78563fbef0ce670aa9 The latter is now implemented using a control, resulting in looser coupling. See also the following commit: f8141e91a693912ea1107a49320e83702a80757a BUG: https://bugzilla.samba.org/show_bug.cgi?id=14087 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-daemon: Factor out new function ctdb_node_become_inactive()Martin Schwenke2019-08-202-0/+45
| | | | | | | | | | This is a superset of ctdb_local_node_got_banned() so will replace that function, and will also be used in the NODE_STOP control. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14087 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tcp: Mark node as disconnected if incoming connection goes awayMartin Schwenke2019-08-162-2/+5
| | | | | | | | | | | | | | To make it easy to pass the node data to the upcall, the private data for ctdb_tcp_read_cb() needs to be changed from tnode to node. RN: Avoid marking a node as connected before it can receive packets BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Fri Aug 16 22:50:35 UTC 2019 on sn-devel-184
* ctdb-tcp: Only mark a node connected if both directions are upMartin Schwenke2019-08-161-3/+17
| | | | | | | | | | | | | Nodes are currently marked as up if the outgoing connection is established. However, if the incoming connection is not yet established then this node could send a request where the replying node can not queue its reply. Wait until both directions are up before marking a node as connected. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tcp: Create outbound queue when the connection becomes writableMartin Schwenke2019-08-163-12/+25
| | | | | | | | | | | | | | | | Since commit ddd97553f0a8bfaada178ec4a7460d76fa21f079 ctdb_queue_send() doesn't queue a packet if the connection isn't yet established (i.e. when fd == -1). So, don't bother creating the outbound queue during initialisation but create it when the connection becomes writable. Now the presence of the queue indicates that the outbound connection is up. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tcp: Use TALLOC_FREE()Martin Schwenke2019-08-161-4/+2
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tcp: Move incoming fd and queue into struct ctdb_tcp_nodeMartin Schwenke2019-08-164-34/+61
| | | | | | | | | | This makes it easy to track both incoming and outgoing connectivity states. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tcp: Rename fd -> out_fdMartin Schwenke2019-08-163-49/+72
| | | | | | | | | | | | | in_fd is coming soon. Fix coding style violations in the affected and adjacent lines. Modernise some debug macros and make them more consistent (e.g. drop logging of errno when strerror(errno) is already logged. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-daemon: Add function ctdb_ip_to_node()Martin Schwenke2019-08-162-5/+21
| | | | | | | | | | | | | | This is the core logic from ctdb_ip_to_pnn(), so re-implement that that function using ctdb_ip_to_node(). Something similar (ctdb_ip_to_nodeid()) was recently removed in commit 010c1d77cd7e192b1fff39b7b91fccbdbbf4a786 because it wasn't required. Now there is a use case. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-daemon: Avoid signed/unsigned comparison by castingMartin Schwenke2019-08-141-1/+1
| | | | | | | | | | | | | | | | | Compiling with -Wsign-compare complains: 1047 | && (call->call_id == CTDB_FETCH_WITH_HEADER_FUNC)) { | ^~ struct ctdb_call is a protocol element, so we can't simply change it. Found by csbuild. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Wed Aug 14 10:29:59 UTC 2019 on sn-devel-184
* ctdb-daemon: Avoid signed/unsigned comparison by declaring as unsignedMartin Schwenke2019-08-141-2/+2
| | | | | | | | | | | | | | | | | | | Compiling with -Wsign-compare complains: ctdb/server/ctdb_call.c:831:12: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare] 831 | if (count <= ctdb_db->statistics.hot_keys[0].count) { | ^~ and ctdb/server/ctdb_call.c:844:13: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare] 844 | if (count <= ctdb_db->statistics.hot_keys[i].count) { | ^~ Found by cs-build. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Return value of ctdb_queue_length() should be unsignedMartin Schwenke2019-08-142-2/+2
| | | | | | | | | | | | | | | | Compiling with -Wsign-compare complains: ctdb/server/ctdb_daemon.c: scope_hint: In function ‘daemon_queue_send’ ctdb/server/ctdb_daemon.c:259:40: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare] ... The struct ctdb_queue member out_queue_length is actually uint32_t, so just return that type. Found by csbuild. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Use select_test_node() in ctdb setdebug simple testMartin Schwenke2019-08-141-1/+1
| | | | | | | There is no requirement for IP addresses here. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Add function select_test_node()Martin Schwenke2019-08-141-0/+8
| | | | | | | Should be used when public IP addresses are not assigned. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tools: Fix usage for "ctdb cattdb"Martin Schwenke2019-08-141-1/+1
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Don't print summary on failure if -e option is specifiedMartin Schwenke2019-08-141-4/+6
| | | | | | | | If there is a failure it will always be the last test run. Don't obscure this by following it with a summary. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Drop mention of non-existent -s optionMartin Schwenke2019-08-141-1/+1
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Add -I <count> option for iterating testsMartin Schwenke2019-08-141-3/+24
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Factor out main test loop into run_tests()Martin Schwenke2019-08-141-24/+33
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Add shellcheck test for some test scripts and includesMartin Schwenke2019-08-141-0/+24
| | | | | | | These files now pass, so we might as well keep them in good shape. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: New variable CTDB_SCRIPTS_TESTS_BIN_DIRMartin Schwenke2019-08-141-1/+4
| | | | | | | This can be used to find ctdb_run_tests and ctdb_local_daemons. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Rename CTDB_SCRIPTS_TESTS_BINDIR to CTDB_SCRIPTS_TESTS_LIBEXEC_DIRMartin Schwenke2019-08-142-5/+5
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Simplify test_wrap scriptMartin Schwenke2019-08-142-22/+8
| | | | | | | Given other improvements, this is now needlessly complex. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Avoid shellcheck warning SC2045Martin Schwenke2019-08-141-1/+5
| | | | | | | SC2045 Iterating over ls output is fragile. Use globs. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Avoid shellcheck warning SC2034Martin Schwenke2019-08-142-1/+1
| | | | | | | SC2034 summary appears unused. Verify use (or export if used externally) Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Avoid shellcheck warning SC2230Martin Schwenke2019-08-141-1/+1
| | | | | | | SC2230 which is non-standard... Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Avoid shellcheck warning SC2188Martin Schwenke2019-08-141-1/+1
| | | | | | | SC2188 This redirection doesn't have a command... Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Avoid shellcheck warning SC2155Martin Schwenke2019-08-143-6/+8
| | | | | | | | | | | | SC2155 Declare and assign separately to avoid masking return values The wscript changes require an identical change in local_daemons.sh. While touching the lines in wscript, escape the backslashes to make them literal backslashes. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Avoid shellcheck warning SC2004Martin Schwenke2019-08-141-4/+4
| | | | | | | SC2004 $/${} is unnecessary on arithmetic variables Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Avoid shellcheck warning SC2164Martin Schwenke2019-08-141-1/+4
| | | | | | | SC2164 Use 'cd ... || exit' or 'cd ... || return' in case cd fails Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Avoid shellcheck warning SC2086Martin Schwenke2019-08-141-6/+7
| | | | | | | SC2086 Double quote to prevent globbing and word splitting Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tools: Drop 'o' option from getopts commandMartin Schwenke2019-08-141-1/+1
| | | | | | | | | | | | Commit 90de5e0594b9180226b9a13293afe31f18576b3d remove the processing for this option but forgot to remove it from the getopts command. Versions of ShellCheck >= 0.4.7 warn on this, so it is worth fixing. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14086 RN: Fix onnode test failure with ShellCheck >= 0.4.7 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb/doc: fix some double-word typosDavid Disseldorp2019-08-124-5/+5
| | | | | Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* ctdb: fix compilation on systems with glibc robust mutexesRalph Boehme2019-08-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | On older systems like SLES 11 without POSIX robust mutexes, but with glib robust mutexes where all the functions are available but have a "_np" suffix, compilation fails in: ctdb/tests/src/test_mutex_raw.c.239.o: In function `worker': /root/samba-4.10.6/bin/default/../../ctdb/tests/src/test_mutex_raw.c:129: undefined reference to `pthread_mutex_consistent' ctdb/tests/src/test_mutex_raw.c.239.o: In function `main': /root/samba-4.10.6/bin/default/../../ctdb/tests/src/test_mutex_raw.c:285: undefined reference to `pthread_mutex_consistent' /root/samba-4.10.6/bin/default/../../ctdb/tests/src/test_mutex_raw.c:332: undefined reference to `pthread_mutexattr_setrobust' /root/samba-4.10.6/bin/default/../../ctdb/tests/src/test_mutex_raw.c:363: undefined reference to `pthread_mutex_consistent' collect2: ld returned 1 exit status This could be fixed by using libreplace system/threads.h instead of pthreads.h directly, but as there has been a desire to keep test_mutex_raw.c standalone and compilable without other external depenencies then libc and libpthread, make the tool developer build only. This should get the average user over the cliff. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14038 RN: Fix compiling ctdb on older systems lacking POSIX robust mutexes Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-scripts: Simplify 01.reclock.scriptMartin Schwenke2019-07-261-35/+21
| | | | | | | | | | | The "init" event is only run once so don't bother caching the configured value of the recovery lock. Add some extra error checking. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Fri Jul 26 04:52:04 UTC 2019 on sn-devel-184
* ctdb-scripts: Drop monitoring of recovery lockMartin Schwenke2019-07-267-115/+0
| | | | | | | The fcntl helper now does a more meaningful check. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Add some 01.reclock.script init event testsMartin Schwenke2019-07-263-0/+50
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Fix 01.reclock.script tests for non-default lockMartin Schwenke2019-07-263-8/+11
| | | | | | | | These tests currently do not do what is expected. They test the default case. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Add tests for cluster mutex lost handlingMartin Schwenke2019-07-262-0/+146
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-mutex: Add support for exiting if the lock file disappearsMartin Schwenke2019-07-262-5/+175
| | | | | | | | | | | | | | | | | If the lock file is inaccessible or the inode number changes then the lock is lost, so exit. This allows the recovery daemon to trigger an election. The ensuing recovery will re-take the lock. By default the lock file is checked every 60 seconds. A lot can happen in 60 seconds but being more aggressive and accessing the lock too often could result in a performance issue for the cluster filesystem. An new optional 2nd argument is added, which is the lock file re-check time in seconds. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-mutex: Add an intermediate asynchronous computation for waitingMartin Schwenke2019-07-261-4/+61
| | | | | | | | | This will allow more conditions to be waited on via additional sub-requests. At the moment this just completes when the parent wait completes. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-mutex: Change parent checking to use an asynchronous computationMartin Schwenke2019-07-265-13/+119
| | | | | | | | | Put the checking for the process being immediately re-parented into the computation too. This will be very rare and doing it consistently makes testing saner. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-mutex: Exit immediately if the lock isn't takenMartin Schwenke2019-07-261-0/+4
| | | | | | | | | | There is no need to wait until the parent kills the helper. The parent will get the initial response, indicating contention or similar, and will then get a separate event indicating that the pipe is gone. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Add test to confirm need for cluster mutex lock file recheckingMartin Schwenke2019-07-262-2/+60
| | | | | | | Remove the lock and a second locker can take the it. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Add cluster mutex testsMartin Schwenke2019-07-265-0/+741
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-mutex: Drop dependency on ctdb_set_helperMartin Schwenke2019-07-261-11/+46
| | | | | | | | This makes the code more explicit and makes testing easier due to less dependencies. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-mutex: Drop unneeded assignmentMartin Schwenke2019-07-261-1/+0
| | | | | | | | | clang warns: ctdb/server/ctdb_mutex_fcntl_helper.c:61:3: warning: Value stored to 'fd' is never read Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-mutex: Update to use modern debug macroMartin Schwenke2019-07-261-5/+4
| | | | | | | | | One of these had a missing space, so this implicitly fixes it. It also drops the need to unnecessarily include common.h, which comes with some dependency baggage. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>