martins/ctdb.git
10 years agoNew version 1.2.64 ctdb-1.2.64
Amitay Isaacs [Thu, 20 Jun 2013 04:40:00 +0000 (14:40 +1000)]
New version 1.2.64

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agorecoverd: Fix printing of node flags from local information
Amitay Isaacs [Wed, 23 Jan 2013 03:35:47 +0000 (14:35 +1100)]
recoverd: Fix printing of node flags from local information

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 124e2a471aeda9c900fd898178a30522d7d74221)

10 years agotools/ctdb: Do not exit prematurely on control timeout if retrying in a loop
Amitay Isaacs [Tue, 18 Jun 2013 04:27:34 +0000 (14:27 +1000)]
tools/ctdb: Do not exit prematurely on control timeout if retrying in a loop

This avoids premature exits from "ctdb stop" and "ctdb continue" due to
intermittent control (e.g. getpnn, getnodemap) timeouts.

This needs a proper fix to distinguish between timeout and failure
conditions and take appropriate action.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit c48583fd238496a81ddc46a21892f0b49559036a)

10 years agotools/ctdb: Remove duplicate command definition for "sync"
Martin Schwenke [Thu, 23 May 2013 06:06:47 +0000 (16:06 +1000)]
tools/ctdb: Remove duplicate command definition for "sync"

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

(cherry picked from commit 9e7b7cd04adc5e66e2ffa4edf463a682aaea379b)

Conflicts:
tools/ctdb.c

10 years agotools/ctdb: Fix racy ipreallocate code
Amitay Isaacs [Thu, 23 May 2013 03:04:06 +0000 (13:04 +1000)]
tools/ctdb: Fix racy ipreallocate code

This code tried to find the recovery master and send an ipreallocate
request to that node.  When a node is stopped, this code asked the
stopped node for recovery master.  Stopped node does not have up-to-date
information on the current recovery master.  So ipreallocate requests
were sent to the wrong node and ignored by that node which is not the
recovery master.

Send ipreallocate request to all active nodes.  That way we guarantee
that the current recovery master will see it and respond to it.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Pair-Programmed-With: Martin Schwenke <martin@meltin.net>

(cherry picked from commit 0577ce3c68e4febf49a1ef5093e918db9d5ec636)

Conflicts:
tools/ctdb.c

10 years agoeventscripts: New configuration varable $CTDB_NFS_DUMP_STUCK_THREADS
Martin Schwenke [Thu, 13 Jun 2013 01:56:25 +0000 (11:56 +1000)]
eventscripts: New configuration varable $CTDB_NFS_DUMP_STUCK_THREADS

If some nfsd threads are still alive after a shutdown during a restart
then this indicates the maximum number of threads for which a stack
trace should be dumped.  This can be useful for trying to determine
why nfsd is stuck.

Signed-off-by: Martin Schwenke <martin@meltin.net>
(cherry picked from commit 2503245db10d567af708a04edd3a3b488c24f401)

10 years agoeventscripts: Add new option $CTDB_MONITOR_NFS_THREAD_COUNT
Martin Schwenke [Thu, 13 Jun 2013 00:17:20 +0000 (10:17 +1000)]
eventscripts: Add new option $CTDB_MONITOR_NFS_THREAD_COUNT

Consider the following example:

1. There are 256 nfsd threads configured.
2. 200 threads are "stuck" in system calls, perhaps waiting for the
   underlying filesystem when an attempt is made to restart NFS.
3. 56 threads exit when NFS is stopped.
4. 56 new threads are started when NFS is started.
5. 200 "stuck" threads exit leaving only 56 threads running.

Setting this option to "yes" makes the 60.nfs monitor event look for
this situation and try to correct it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
(cherry picked from commit 99b0d8b8ecc36dfc493775b9ebced54539c182d2)

Conflicts:
config/events.d/60.nfs

10 years agoNew version 1.2.63 ctdb-1.2.63
Amitay Isaacs [Mon, 17 Jun 2013 03:19:39 +0000 (13:19 +1000)]
New version 1.2.63

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotdb: Update TDB library to 1.2.12 from upstream
Amitay Isaacs [Thu, 13 Jun 2013 02:52:38 +0000 (12:52 +1000)]
tdb: Update TDB library to 1.2.12 from upstream

This comprises of following patches from Samba upstream.

d1feccb35e987545f4ae8e3f4eb0b4fc741e7e7e tdb: change version to tdb-1.2.12
1f269fcc6e2bb46b765d547eb1add2bc52272c47 tdb: Add another overflow check to tdb_expand_adjust
d9b4f19e73f241a1ccf64f04c3cc28d481550bb7 tdb: Make tdb_recovery_allocate overflow-safe
8b215df4454883b3733733af4f49f87eb0a2a46a tdb: Make tdb_recovery_size overflow-safe
7ae09a9695bcc5fad606441db3ab6e413b9d48ce tdb: add proper OOM/ENOSPC handling to tdb_expand()
854c5f0aac03c7c6d7e1b37997dcdc848fec1499 tdb: add overflow detection to tdb_expand_adjust()
e19d46f7e31a32e2b5ae3ec05e13f32b8ac2109d tdb: add overflow/ENOSPC handling to tdb_expand_file()
a07ba17e0c91d726416db946e6f65b064b2d17ec tdb: add a 'new_size' helper variable to tdb_expand_file()
4483bf143ddfee9ec07aed8f124559b00f757d9a tdb: Add overflow-checking tdb_add_off_t
3bd686c5ad4756af1033ac14ba09a40156cc6d47 tdb: fix logging of offets and lengths.
cd4b413cb0574c459c1c24cf07f8d6b44f5fc077 build: Remove autoconf build system
11f467d0bd8e2264f311d82f3299443b99526bb3 tdb: include information about hash function being used in tdbtool info output
c8c0bf74805c61b1379dab1d4529df0004872bb4 tdb: Fix blank line endings
a92c08e18bca2f1db671dc5e2d0db4adbf39752d tdb: Little format change
68698b4e64831d2fdf762b5f8577ff404f10a3cb tdb: Slightly simplify tdb_expand_file
2f4b21bb57c4f96c5f5b57a69d022c142d8088d5 ntdb: switch between secrets.tdb and secrets.ntdb depending on 'use ntdb'
a7fdd4f7c2e64eedf12cb46c3435edbec772a4ab tdb: Slightly simplify transaction_write
fcb345f5d6be9659a0f8a5afe62a937010a33d5c tdb: Make tdb_release_transaction_locks use tdb_allrecord_unlock
5929e38b6cdbd4f9721293a19f079ceae1af76b0 tdb: Don't segfault if tdb_open_ex for check failed
3534e4e8d5bebfaaaef5886dcea219a7e4047fc7 tdb: Factor out the retry loop from tdb_allrecord_upgrade
1f93f0836484ccc1abe335f5bd2cfd35df0b7631 tdb: Simplify fcntl_lock() a bit
542400a966039178effd6c8da932ed3a8d749131 tdb: Use tdb_null in freelistcheck
68559b787e7c9a83e055493bde638ec02e1097d1 tdb: Enhance lock tracking a bit
05235d5b444558f6d06ef12ea7d74850800425cf tdb: Fix a typo
72cd5d5ff664dc46afb3dd6a5ea45a28ef7b8591 tdb: Remove "header" from tdb_context
71247ec4bdefb3a1b16619f7ea7404bcbafb5b60 tdb: Pass argument "header" to check_header_hash
1436107b0769c88e7eb50057b5f05ad5b8573990 tdb: Pass argument "header" to tdb_new_database
80a6fe84271d15cc22caa3d08768ab5559ef9ed7 Remove some unused variables.
f2d67af7bc0b316f54d6cc1a44d07f1b24244378 tdb: Fix undefined prototype warnings
1beb4bc9d12fb124935e9e4710f48ad616dacc60 tdb: Fix \n in error messages
a444bb95a270ca5b331041c11a7e785c1e0559b7 tdb: Add a comment explaining the "check"
3109b541c9b2f0063e1ccb0cdaec0a8e388b29b4 tdb: Make tdb_new_database() follow a more conventional style
d972e6fa74b6499403d4c3d3c6a84cbda7eded39 tdb: Fix a typo
c04de8f3a4deba0062f8cdbcbe74d3735a80b735 tdb: Fix a typo
24755d75b0ee7170195bc26cf28bab4ffdb6f752 tdb: Use tdb_lock_covered_by_allrecord_lock in tdb_unlock
f8dafe5685008671f4f983a4defc90b4a05cf992 tdb: Factor out tdb_lock_covered_by_allrecord_lock from tdb_lock_list
26b8545df44df7e60ba0ba7336ffbdda8a14e423 tdb: Simplify logic in tdb_lock_list slightly
0f4e7a1401998746a6818b9469ab369d70418ac1 tdb: Slightly simplify tdb_lock_list
116ec13bb0718eb1de1ac1f4410d5c33f1db616f tdb: Fix blank line endings
7237fdd4ddc0b9c848b5936431b4f8731ce56dba tdb: Fix a comment
d2b852d79bd83754d8952a0e3dece00e513549f2 tdb: Fix a typo
2c3fd8a13e7dde23a23404cd88078a04c8b338ea tdb: Fix a missing CONVERT
c9053796b389758e8bacff4cd37d633fd65171f9 tdb: Improve the documentation of tdb_reopen() and tdb_close().
7f08365a28770fdcc1bb625d8a16d11d8f15c29a tdb: Fix possible crash bugs in the python tdb code.
ede2aaef281048123cacab9ae879f5c546787080 lib/tdb: Rename manpages/ to man/.
68c6dcb0942244f542eec7bbe5fba78ef7f66051 docs: man tdbtool: Add missing meta data.
c62f8baff878001ead921112dd653ff69d1cfe7d tdb: Make tdb robust against improper CLEAR_IF_FIRST restart
37fd93194db10fc832ed3fa1ec880ebc26be904b tdb: Make robust against shrinking tdbs
100d38d6e0fae1dc666ae43941570c9f106b73c2 tdb: add -e option to tdbdump (and docment it).
ffde8678910ae838588ab380b48a544333f81241 tdb: tdbdump should log errors, and fail in that case.
90f463b25f7bb0bc944732773c56e356834ea203 tdb: add tdb_rescue()
a168a7c791a4be1730a370d059b3a1073fbb0bdd tdb: Fix a typo
1f50b6c3aefe9a7ac64641b1e9c23e014459647f tdb/test: fix build on OSF/1
41cffa3c8b126570203e32c2024d5a8f439b529e doc: Remove build/ from doxygen config or it will not work in brew.
ea6b8ee026a4c53d9dfb5a42e4d9e485b89018e3 lib/tdb: Fix format string errors found by -Werror=format in tdb tests
c92a5670e3d60decbc13bd8680de37184bc12815 pytdb: Check if the database is closed before we touch it
a8e88332a394f4a4c3e43b496738008fba39d39f pytdb: Check for errors parsing strings into TDB_DATA
66f59f040984bef5023fc844097b85bebee88f09 tdb: finish weaning off err.h.
3c4263e7580143c69225729f5b67f09c00add2fd tdb: don't use err.h in tests.
1783fe34433f9bb4b939de3231a7c296390ec426 tdb: make TDB_NOSYNC merely disable sync.
f7f6992c1e6ee8ac4a55c2fddf169ac695362036 autobuild: always set TDB_NO_FSYNC.
bf5934ca1b80930d8fd2f19ef12e32092b34fa4d tdb/wscript: Remove unecessary semicolons.
e2caba054f977b631720f8dc2528ba03dc237122 tdb: remove unused debug_fprintf() macro that breaks the build
0688cf102d2a513875d1832ad0de6052b837a72a tdb:tests: fix use of a non-existent word (existant)
c8877d8f63ea367401fae4377cd28ee91b58d9e3 build: Remove unused release scripts for tdb
593e731097bc6f2fd50034f5e3ddac017894e584 lib/tdb: Update ABI
3fdeaa3992bb0599613e20d8e3248c478897531f lib/tdb: Add/expose lock functions to support CTDB
4442c0b2c92e4b2e88661e15022228c5f6547112 lib/tdb: fix transaction issue for HAVE_INCOHERENT_MMAP.
c12970cc91cb4da8976801e194e29e33e02b340a lib/tdb: fix test/run-die-during-transaction when HAVE_INCOHERENT_MMAP.
330e3e1b91ecbf99af3b598b324f21b5eff933fd lib/tdb: fix missing return 0 code.
fde694274e1e5a11d1473695e7ec7a97f95d39e4 lib/tdb: fix OpenBSD incoherent mmap.
eafd83736918bc5953e4a91cf2d893e68f2da2a2 lib/tdb: fix up run-die-during-transaction test cases on Solaris.
3272ba0d2d63e6a7d00972bc2c052aee84f073fd lib/tdb: remove unnecessary XOPEN and FILE_OFFSET_BITS defines in test/
583ffeae404cc632eebc43fed054391a59dffee2 lib/tdb: fix tests for standalone out-of-tree.
4d58d0fa8f936e7efdc02e31c053d42a47b3e62a tdb: build and run unit tests in tdb/test/
205242e1769f96e0e8fccd52378965d35dd02093 tdb/test: fix up tests for use in SAMBA tdb code.
8fa345d952328c5866f3a0f835f3599343c51b00 tdb: wean CCAN-style unit tests off of tap.
0802791081ba39298aa93f0e6860c3b62800df73 tdb: import unit tests from CCAN into tdb/test/
390b9a2dd8447ecd16e3957c02fa886781797733 tdb: make tdb_private.h idempotent.
eff69aa0f908f5cb44b3cb846c8a4ada874240fa Add "repack" command to tdbtool.
7b42ceb414d3e14c411dd95dcd0b200113fe1191 Fix compile when TDB_TRACE is enabled.
c1e9537ed0f58404fed96a7aa9e581b8ebb1fb60 tdb: Use tdb_parse_record in tdb_update_hash
5767224b7f4703c3195aa69eef4352d80980f95e tdb: don't free old recovery area when expanding if already at EOF.
3a2a755e3380a8f81374009d463cd06161352507 tdb: use same expansion factor logic when expanding for new recovery area.
664add17757836c5ee98618aef11371f412b6e44 tdb: Avoid a malloc/memcpy in _tdb_store
b64494535dc62f4073fc6302847593ed6e6ec38b tdb: be more careful on 4G files.
20789bfdde37ee3140422b5599d41a280c01d29f tdb: Fix python documentation for tdb module
3741cf999e0f05a831d88330ac6bfa7ad34c2ec7 Remove unused variable.
3e6e1aed949a4483fc38607e443b5c8b715aca3b Fix a bunch of "warning: variable ‘XXXX’ set but not used [-Wunused-but-set-variable]" warnings from the new gcc.
86afe83d867229b11fd4ec9cb6e29af698cacdef waf: Factor checking for undefined symbol flags out into separate method.
3585abcd4cc1b6ffeeb7f64abe3d21a12f9633f6 pytdb: Shorter description which fits on a single line.
774f85649b5d9f8872ebfdd359964330b4ff436a tdb: Only check for pkg-config file when checking for system tdb.
31912781ca84db9b27264b5182729d1097c0661d wafsamba: Only install .pc files if libraries are public.
a5025a3c2fa83c67e0a53611ad8fbe264888a590 tdb: Install pkg-config file.
ee720fc19cebf9108711429dfe25ccaf192e2c7e tdb: increment sequence number in tdb_wipe_all().
e01f3108ff447239fb3cb2f89b4749c5f7b88c3b tdb: remove 'EOF' print from tdbrestore
5eecc854236f0b943aaa89e0c3a46f9fbd208ca9 tdb2: create tdb2 versions of various testing TDBs.
6bc59d77b64d1ecbe5c906ed2fa80a7b8ca5d420 tdb_store: check returns for 0, not -1.
4fa51257b283c2e8bb415cc7f9c001d64c8a2669 tdb: enable VALGRIND to remove valgrind noise.
43ab5aa390769ee9b57918cf5b57aa4a22586805 lib/tdb/python/tests/simple.py: don't assume TDB ordering.
73c31f044e32103276558a194698ea6cf876b4f2 tdb: fix a build warning.
bf3b2e2aee284c85ecea6a3142bc1fa5344b430a Support the 'PYTHON' environment variable.
1804d9a64662d37f6c7c50bdd7b8edd80f42192b tdb_backup: avoid transaction on backup file, use lockall
36cfa7b79e36d880cdbf24d0769558be44d0edda tdb: make sure we skip over recovery area correctly.
cb884186a55c9ef8aca6ee48b16423b3c881e689 tdb_expand: limit the expansion with huge records
094ab60053bcc0bc3542af8144e394d83270053e tdb: tdb_repack() only when it's worthwhile.
6aa72dae8fc341de5b497f831ded1f8f519fa8fb tdb: fix transaction recovery area for converted tdbs.
0080f944b47f3afa676153e5da7093a8667fc005 tdb: Fix Coverity ID 2238: SECURE_CODING
25397de589e577e32bb291576b10c18978b5bc4e tdb: Fix Coverity ID 2192: NO_EFFECT
bfce962c8f5219e72a07810a663a14542355927d tdb: rename convert_string() to tdb_convert_string()
c56e3ccfc9eafbb69b03dc40346e3115bec42ef6 lib: don't install public headers if a private library
7b948a39e1783ff4732f9734830b0544d6a814b1 tdb: use public_headers to install header files
0a0ebd73fb98002f099544eca5deaf6763790277 tdb: use system include style for system headers
949427c208159f4ac580f547dd5465a70b4751b7 python: use os.environ[] instead of os.putenv()
91cad71390bd2a0330891083c65d3f9000b74657 tdb: Fix a C++ warning
8b8caac6d0ac980e59bc5bcbfb06502deebb9f42 build: removed the old autogen.sh and autogen-waf.sh scripts
b42afa0edf375c944d39a888f4db422e8d2b13cf tdb: Added doxygen documentation.
005c6370cdaab69d4228ecbf5e7369ebc61b86ae waf: ensure "make dist" works from a clean git tree for all libraries
24d5a7202ab521b92eb07c93647ae2d381e181a5 tdbrestore: Update to GPLv3+, remove old FSF address.
5792fa90ace06f736661d9924ec9a75c3a0a9771 s4-python: Only set BASETYPE flag if subclassing is supported.
51239bb26a714bf4c41fb15fde211df1255f9468 talloc/tdb/tevent: Remove obsolete signatures files.
b222615b5978aa78e82af79359b7cc3baec0bc87 tdb: add ABI/tdb-1.2.9.sigs
cac57328a6077dc428396402036636095f139569 tdb: tdb_summary() support.
7ea1b767977c8c201c0f5bfaeb01f96af4b51f7b tdb: setup TEST_DATA_PREFIX for make test
b83672b36c1ea8c35833c40c3919b63809f16624 tdb:tdbtorture: use TEST_DATA_PREFIX for files
d81ceeb9833ec80d7ab21b34e4b3af3d79aeb845 tdb:tdbtest: use TEST_DATA_PREFIX for files
9e8a04984327ffae611165244a159ff9c6ca30f4 tdb: Remove autotools support.
46ee6908be64c4405b3a8f7477abc119aa060020 tdb: add ABI/tdb-1.2.8.sigs
c754fad5712cc7c1912f27eb5595c12cf65e55c6 tdb: Bump version number after symbol versioning changes.
51e7244269e9c14a920f91a485cda6c785b2fc85 pytdb: Make PyTdb variable static.
87337383572324e3d1d00ed710614ebe217aa2b2 build: introduce SAMBA_CHECK_PYTHON_HEADERS
57f2f1d72a70a80e61a2ed6f1abc63a177a590ab waf: remove the restriction that private libraries must not have a vnum
ebe2867fc2c01fb5288d62eedb0e2f43788b9f27 waf-abi: auto-generate per-symbol versions from ABI files
735c1cd2da15167748e92ba6de48fdb5169db587 s4-pkgconfig: add @LIB_RPATH@ to our link flags
989d8803f28826e6541667127abad801c4fa4566 tdb:common/open.c - use "discard_const_p" for certain "tdb->name" assignments
d2560cd7dc106d7853442133f237001f68bcb971 tdb:tdbstore.c - remove an useless '\'
2ac5cedb719d220db412d0bdc69e34bad9ab26f1 Avoid the use of PyAPI_DATA, which is for internal Python API's.
dedd064aa825edd57f992b12218a184398db9586 tdb: set tdb->name early, as it's needed for tdb_name()
f0a472a2d678dd0374181f1a6ac0a3d35503636e waf: added reconfigure targets to our libraries
1aa8308c30962ac04a2997acaa7f2a7458729cc2 tdb: Use waf by default.
3deece559159150a0710d8160f39583ba7f2e582 s4: Remove the old perl/m4/make/mk-based build system.
50256c01d061c6d73bb2d8ee2c60785d58748e6c waf: Only specify vnum for non-private libraries.
49ef2888193dd7cc37c3fe0a980b7cc1abdac805 waf: Rename some BUNDLED_ functios to PRIVATE_.
dec00bf0974ea3b5079c32e2a6e6253954297253 tdb: Revert re-addition of tdb_set_logging_function.
ee913f45683e66d4391944e034217a56d42e7ab5 tdb: commit the version 1.2.7 signatures
c529317fe2b48e045b35a613cfd1ad3f03b68435 Lowercase socket_wrapper name.
62c4af99428abb2d4ac1b18454d72e0c8cbb67e8 tdb: Set _PUBLIC_ in C file rather than header files (Debian bug 600898)
7cba3cfac8781061e4114573517b30baedbf891a waf: replace the is_bundled option with private_library
713900b81297548c44a890c3bca1dde9019af8bc s4-build: fixed some formatting
05c1beb6b47e607dac9850e81cef775a1d9b00ae tdb: Bump version to 1.2.7 after addition of pytdb.__version__.
bb0017615d44b66828c98a408ca15b50956f3e91 waf: fixed exit status of test suites
20d39691a8eecd57b27cb709a70c50bf572b8114 tdb: Only use system pytdb when using system tdb.
e805bf52c9ed32bd53759996b5700c5d582a2a58 tdb: Support using system pytdb.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoNew version 1.2.62 ctdb-1.2.62
Amitay Isaacs [Mon, 22 Apr 2013 04:26:56 +0000 (14:26 +1000)]
New version 1.2.62

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoctdbd: Set num_clients statistic from ctdb->num_clients
Amitay Isaacs [Fri, 19 Apr 2013 03:29:04 +0000 (13:29 +1000)]
ctdbd: Set num_clients statistic from ctdb->num_clients

This fixes the problem of "ctdb statisticsreset" clearing the number of
clients even when there are active clients.

Values returned in statistics for frozen, recovering, memory_used are based on
the current state of CTDB and are not maintained as statistics.  This should
include num_clients as well.

Currently ctdb->num_clients is unused. So use that to track the number of
clients and fill in statistics field only when requested.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit dc4ca816630ed44b419108da53421331243fb8c7)

11 years agoctdbd: Log PID file creation and removal at NOTICE level
Martin Schwenke [Mon, 22 Apr 2013 03:52:04 +0000 (13:52 +1000)]
ctdbd: Log PID file creation and removal at NOTICE level

Unexpected removal of this file can have serious consequences, so it
is best if this is logged at the default level.

Signed-off-by: Martin Schwenke <martin@meltin.net>
(cherry picked from commit bfed6a8d1771db3401d12b819204736c33acb312)

11 years agoscripts: Crash cleanup script should pass a tag to logger
Martin Schwenke [Tue, 16 Apr 2013 06:10:04 +0000 (16:10 +1000)]
scripts: Crash cleanup script should pass a tag to logger

Signed-off-by: Martin Schwenke <martin@meltin.net>
11 years agoscripts: ctdb-crash-cleanup.sh uses initscript to see if ctdbd is running
Martin Schwenke [Mon, 15 Apr 2013 05:42:55 +0000 (15:42 +1000)]
scripts: ctdb-crash-cleanup.sh uses initscript to see if ctdbd is running

"ctdb ping" (or "ctdb status") can time out.  How many times should we
try?

Instead, depend on the initscript to implement something sane.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
(cherry picked from commit 90cb337e5ccf397b69a64298559a428ff508f196)

Conflicts:
config/ctdb-crash-cleanup.sh

11 years agoinitscript: Use a PID file to implement the "status" option
Martin Schwenke [Mon, 15 Apr 2013 05:18:12 +0000 (15:18 +1000)]
initscript: Use a PID file to implement the "status" option

Using "ctdb ping" and "ctdb status" is fraught with danger.  These
commands can timeout when ctdbd is running, leading callers to believe
that ctdbd is not running.  Timeouts could be increased but we would
still have to handle potential timeouts.

Everything else in the world implements the "status" option by
checking if the relevant process is running.  This change makes CTDB
do the same thing and uses standard distro functions.

This change is backward compatible in sense that a missing
/var/run/ctdb/ directory means that we don't do a PID file check but
just depend on the distro's checking method.  Therefore, if CTDB was
started with an older version of this script then "service ctdb
status" will still work.

This script does not support changing the value of CTDB_VALGRIND
between calls.  If you start with CTDB_VALGRIND=yes then you need to
check status with the same setting.  CTDB_VALGRIND is a debug
variable, so this is acceptable.

This also adds sourcing of /lib/lsb/init-functions to make the Debian
function status_of_proc() available.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
(cherry picked from commit 687e2eace4f48400cf5029914f62b6ddabb85378)

Conflicts:
config/ctdb.init

11 years agoctdbd: Add --pidfile option
Amitay Isaacs [Fri, 19 Apr 2013 06:47:32 +0000 (16:47 +1000)]
ctdbd: Add --pidfile option

Default is not to create a pid file.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
(cherry picked from commit 996e74d3db0c50f91b320af8ab7c43ea6b1136af)

Conflicts:
server/ctdb_daemon.c

11 years agoctdbd: Change some fork() calls to ctdb_fork()
Martin Schwenke [Fri, 19 Apr 2013 05:16:19 +0000 (15:16 +1000)]
ctdbd: Change some fork() calls to ctdb_fork()

This guarantees that ctdb_set_child_info() is called.

Signed-off-by: Martin Schwenke <martin@meltin.net>
11 years agoutil: ctdb_fork() should call ctdb_set_child_info()
Martin Schwenke [Fri, 19 Apr 2013 04:54:03 +0000 (14:54 +1000)]
util: ctdb_fork() should call ctdb_set_child_info()

For now we pass NULL as the child name.  Later we'll give ctdb_fork()
and friends an extra argument and pass that through.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
(backported from commit ba8866d40125bab06391a17d48ff06a4a9f9da89)

11 years agoutil: New functions ctdb_set_child_info() and ctdb_is_child_process()
Martin Schwenke [Fri, 19 Apr 2013 04:42:44 +0000 (14:42 +1000)]
util: New functions ctdb_set_child_info() and ctdb_is_child_process()

Must be called by all child processes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
(backported from commit 59b019a97aad9a731f9080ea5be14d0dbdfe03d6)

11 years agoLogging: Fix breakage when freeing the log ringbuffer
Martin Schwenke [Fri, 19 Apr 2013 04:35:49 +0000 (14:35 +1000)]
Logging: Fix breakage when freeing the log ringbuffer

Commit c6e1b84595039edb5c49a5851b440710dc0e2ac1 broke fetching from
the log ringbuffer.  The solution there is still generally good: there
is no need to keep the ringbuffer in children created by
ctdb_fork()... except for those special children that are created to
fetch data from the ringbuffer!

Introduce a new function ctdb_fork_no_free_ringbuffer() that does
everything ctdb_fork() needs to do except free the ringbuffer (i.e. it
is the old ctdb_fork() function).  The new ctdb_fork() function just
calls that function and then frees the ringbuffer in the child.

This means all callers of ctdb_fork() have the convenience of having
the ringbuffer freed, apart from the special case in the ringbuffer
fetching code where we call ctdb_fork_no_free_ringbuffer() instead.

Signed-off-by: Martin Schwenke <martin@meltin.net>
(backported from commit 00db5fa00474f8a83f1aa3b603fd756cc9b49ff4)

11 years agoctdb_call: don't bump the rsn in ctdb_become_dmaster() any more
Michael Adam [Wed, 3 Apr 2013 10:02:59 +0000 (12:02 +0200)]
ctdb_call: don't bump the rsn in ctdb_become_dmaster() any more

This is now done in ctdb_ltdb_store_server(), so this
extra bump can be spared.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-By: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit cad3107b12e8392f786f9a758ee38cf3a3d58538)

11 years agoFix a severe recovery bug that can lead to data corruption for SMB clients.
Michael Adam [Wed, 3 Apr 2013 09:40:25 +0000 (11:40 +0200)]
Fix a severe recovery bug that can lead to data corruption for SMB clients.

Problem:
Recovery can under certain circumstances lead to old record copies
resurrecting: Recovery selects the newest record copy purely by RSN. At
the end of the recovery, the recovery master is the dmaster for all
records in all (non-persistent) databases. And the other nodes locally
hold the complete copy of the databases. The bug is that the recovery
process does not increment the RSN on the recovery master at the end of
the recovery. Now clients acting directly on the Recovery master will
directly change a record's content on the recmaster without migration
and hence without RSN bump.  So a subsequent recovery can not tell that
the recmaster's copy is newer than the copies on the other nodes, since
their RSN is the same. Hence, if the recmaster is not node 0 (or more
precisely not the active node with the lowest node number), the recovery
will choose copies from nodes with lower number and stick to these.

Here is how to reproduce:

- assume we have a cluster with at least 2 nodes
- ensure that the recmaster is not node 0
  (maybe ensure with "onnode 0 ctdb setrecmasterrole off")
  say recmaster is node 1
- choose a new database name, say "test1.tdb"
  (make sure it is not yet attached as persistent)
- choose a key name, say "key1"
- all clustere nodes should ok and no recovery running
- now do the following on node 1:

1. dbwrap_tool test1.tdb store key1 uint32 1
2. dbwrap_tool test1.tdb fetch key1 uint32
   ==> 1
3. ctdb recover
4. dbwrap_tool test1.tdb store key1 uint32 2
5. dbwrap_tool test1.tdb fetch key1 uint32
   ==> 2
4. ctdb recover
7. dbwrap_tool test1.tdb fetch key1 uint32
   ==> 1
   ==> BUG

This is a very severe bug, since when applied to Samba's locking.tdb
database, it means that for SMB clients on clustered Samba there is
the potential for locking out oneself from previously opened files
or even worse, data corruption:

Case 1: locking out

- client on recmaster opens file
- recovery propagates open file handle (entry in locking.tdb) to
  other nodes
- client closes file
- client opens the same file
- recovery resurrects old copy of open file record in locking.tdb
  from lower node
- client closes file but fails to delete entry in locking.tdb
- client tries to open same file again but fails, since
  the old record locks it out (since the client is still connected)

Case 2: data corruption

- clien1 on recmaster opens file
- recovery propagates open file info to other nodes
- client1 closes the file and disconnects
- client2 opens the same file
- recovery resurrects old copy of locking.tdb record,
  where client2 has no entry, but client1 has.
- but client2 believes it still has a handle
- client3 opens the file and succees without
  conflicting with client2
  (the detached entry for client1 is discarded because
   the server does not exist any more).
=> both client2 and client3 believe they have exclusive
  access to the file and writing creates data corruption

Fix:

When storing a record on the dmaster, bump its RSN.

The ctdb_ltdb_store_server() is the central function for storing
a record to a local tdb from the ctdbd server context.
So this is also the place where the RSN of the record to be stored
should be incremented, when storing on the dmaster.

For the case of the record migration, this is currently done in
ctdb_become_dmaster() in ctdb_call.c, but there are other places
such as in recovery, where we should bump the RSN, but currently
don't do it.

So moving the RSN incrementation into ctdb_ltdb_store_server fixes
the recovery-record-resurrection bug.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-By: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit feb1d40b21a160737aead22e398f3c34ff3be8de)

11 years agoREADONLY: dont schedule for fast vacuum deletion if any of the readonly record flags...
Ronnie Sahlberg [Mon, 20 Feb 2012 19:54:09 +0000 (06:54 +1100)]
READONLY: dont schedule for fast vacuum deletion if any of the readonly record flags are set
(cherry picked from commit b3307d78fd15f446b423f8cdd1e403f89fbe8ac8)

11 years agoReadOnly: Make sure we dont try to fast-vacuum records that are set for readonly...
Ronnie Sahlberg [Mon, 20 Feb 2012 10:13:46 +0000 (21:13 +1100)]
ReadOnly: Make sure we dont try to fast-vacuum records that are set for readonly delegation
(cherry picked from commit 303134cf10a08ce61954d5de9025d9bbcb5f75ef)

11 years agoctdb_ltdb_store_server: when storing a record that is not to be scheduled for deletio...
Michael Adam [Thu, 7 Apr 2011 10:17:42 +0000 (12:17 +0200)]
ctdb_ltdb_store_server: when storing a record that is not to be scheduled for deletion, remove it from the delete queue

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 489148e465e2b8aed87ea836e3518f43490671ca)

11 years agovacuum: add ctdb_local_remove_from_delete_queue()
Michael Adam [Thu, 7 Apr 2011 10:17:16 +0000 (12:17 +0200)]
vacuum: add ctdb_local_remove_from_delete_queue()

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit a5065b42a98c709173503e02d217f97792878625)

11 years agoNew version 1.2.61 ctdb-1.2.61
Amitay Isaacs [Fri, 5 Apr 2013 05:26:24 +0000 (16:26 +1100)]
New version 1.2.61

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agolockwait: Pass CTDB daemon PID on command line
Amitay Isaacs [Fri, 5 Apr 2013 04:31:26 +0000 (15:31 +1100)]
lockwait: Pass CTDB daemon PID on command line

In lockwait helper process we cannot rely on getppid() to find the pid
of CTDB daemon as CTDB daemon can go away before the helper executes. In
which case, ctdb helper process will hang around forever.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agorecoverd/takeover: Use IP->node mapping info from nodes hosting that IP
Amitay Isaacs [Fri, 5 Apr 2013 02:34:06 +0000 (13:34 +1100)]
recoverd/takeover: Use IP->node mapping info from nodes hosting that IP

When collating IP information for IP layout, only trust the nodes that are
hosting an IP, to have correct information about that IP.  Ignore what all the
other nodes think.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 1c7adbccc69ac276d2b957ad16c3802fdb8868ca)

11 years agostatd-callout: Make sure statd callout script always runs as root
Amitay Isaacs [Wed, 3 Apr 2013 03:44:08 +0000 (14:44 +1100)]
statd-callout: Make sure statd callout script always runs as root

In RHEL 6+, rpc.statd runs as "rpcuser" instead of root as on RHEL 5. This
prevents CTDB tool commands talking to daemon since "rpcuser" cannot access
CTDB socket.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Pair-Programmed-With: Martin Schwenke <martin@meltin.net>
(cherry picked from commit fe8c4880b371492a38554868d4ca10918c54e412)

Conflicts:
packaging/RPM/ctdb.spec.in

11 years agoclient: Set the socket non-blocking only after connect succeeds
Amitay Isaacs [Mon, 18 Mar 2013 02:45:08 +0000 (13:45 +1100)]
client: Set the socket non-blocking only after connect succeeds

If the socket is set non-blocking before connect, then we should catch
EAGAIN errors and retry. Instead of adding a random number of retries,
better to wait for connect to succeed and then set the socket to
non-blocking.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 524ec206e6a5e8b11723f4d8d1251ed5d84063b0)

11 years agocommon/messaging: Use the jenkins hash in ctdb_message
Volker Lendecke [Wed, 3 Apr 2013 12:59:21 +0000 (14:59 +0200)]
common/messaging: Use the jenkins hash in ctdb_message

This give a better hash distribution
(cherry picked from commit f7f8bde2376f8180a0dca6d7b8d7d2a4a12f4bd8)

11 years agocommon/messaging: use tdb_parse_record in message_list_db_fetch
Volker Lendecke [Fri, 5 Apr 2013 02:11:31 +0000 (13:11 +1100)]
common/messaging: use tdb_parse_record in message_list_db_fetch

This avoids malloc/free in a hot code path.
(cherry picked from commit c137531fae8f7f6392746ce1b9ac6f219775fc29)

11 years agocommon/messaging: Abstract db related operations inside db functions
Amitay Isaacs [Wed, 3 Apr 2013 04:08:14 +0000 (15:08 +1100)]
common/messaging: Abstract db related operations inside db functions

This simplifies the use of message indexdb API and abstracts tdb related code
inside the API.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit bf7296ce9b98563bcb8426cd035dbeab6d884f59)

11 years agocommon/messaging: Don't forget to free the result returned by tdb_fetch()
Amitay Isaacs [Tue, 2 Apr 2013 05:57:51 +0000 (16:57 +1100)]
common/messaging: Don't forget to free the result returned by tdb_fetch()

This fixes a memory leak in the messaging code.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 20be1f991dd75c2333c9ec9db226432a819f57ba)

11 years agocommon/messaging: Free message list header if all message handlers are freed
Amitay Isaacs [Tue, 2 Apr 2013 01:08:39 +0000 (12:08 +1100)]
common/messaging: Free message list header if all message handlers are freed

This makes sure that even if the srvids are not deregistered, the header
structure is freed when the last message handler has been freed as a result of
client going away.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 4e1ec7412866f2d31c41de1bec0fbf788c03051b)

11 years agoNew version 1.2.60 ctdb-1.2.60
Amitay Isaacs [Mon, 25 Mar 2013 07:05:07 +0000 (18:05 +1100)]
New version 1.2.60

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agolockwait: Allow for zero length key requests
Amitay Isaacs [Thu, 14 Mar 2013 04:44:44 +0000 (15:44 +1100)]
lockwait: Allow for zero length key requests

Samba sends zero length key requests for notify database. To support older
Samba behaviour for now, allow zero length key requests. Zero length key is
encoded as "NULL" string.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agolockwait: Pass all locking information on commandline to lockwait helper
Amitay Isaacs [Wed, 13 Mar 2013 06:05:00 +0000 (17:05 +1100)]
lockwait: Pass all locking information on commandline to lockwait helper

Simplify lockwait code by getting rid of the communication between ctdbd
and ctdb lockwait helper child by passing all the locking information
on command line.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agolockwait: Check result of lockwait child
Volker Lendecke [Tue, 12 Mar 2013 12:35:17 +0000 (13:35 +0100)]
lockwait: Check result of lockwait child

11 years agolockwait: fix a comment typo
Michael Adam [Wed, 13 Mar 2013 08:12:50 +0000 (09:12 +0100)]
lockwait: fix a comment typo

Signed-off-by: Michael Adam <obnox@samba.org>
11 years agoutil: Add hex_decode_talloc() to decode hex string into a binary blob
Amitay Isaacs [Wed, 13 Mar 2013 11:57:44 +0000 (22:57 +1100)]
util: Add hex_decode_talloc() to decode hex string into a binary blob

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 307416afda707b687f5e89e8438e45c154a4c806)

11 years agologging: Do not ignore stdout/stderr from the exec'd children
Amitay Isaacs [Wed, 13 Mar 2013 00:46:18 +0000 (11:46 +1100)]
logging: Do not ignore stdout/stderr from the exec'd children

To log debugging information from child processes that are started
with vfork and exec, do not set close_on_exec on STDOUT and STDERR for
that process.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 08c53ee609b80f87450a7a1d7dd24fbcdf5ab7bc)

11 years agoNew Version 1.2.59 ctdb-1.2.59
Amitay Isaacs [Wed, 6 Mar 2013 06:48:44 +0000 (17:48 +1100)]
New Version 1.2.59

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoctdbd: Exec lockwait helper for locking a record
Amitay Isaacs [Mon, 18 Feb 2013 07:05:28 +0000 (18:05 +1100)]
ctdbd: Exec lockwait helper for locking a record

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoctdbd: Create a standalone helper for record locking
Amitay Isaacs [Mon, 18 Feb 2013 07:04:07 +0000 (18:04 +1100)]
ctdbd: Create a standalone helper for record locking

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agotevent: optimize adding new timer events
Stefan Metzmacher [Fri, 22 Feb 2013 11:45:39 +0000 (12:45 +0100)]
tevent: optimize adding new timer events

There're two cases:

1. Adding a timer with a zero timestamp.
   Such events were used before we had immediate events.
   It's likely that there're a lot of this events
   and we need to add new ones in fifo order.

2. Adding a timer with a real timestamp.
   As this timestamps typically get higher:-)
   it's better to traverse the existing list from
   the tail.

This is not completely optimal, but it should be better
than before.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
11 years agocommon/io: For scheduling immediate events use tevent_schedule_immediate
Amitay Isaacs [Fri, 22 Feb 2013 01:59:39 +0000 (12:59 +1100)]
common/io: For scheduling immediate events use tevent_schedule_immediate

tevent_schedule_immediate() is much more efficient at handling events that need
to be processed immediately rather than creating timed events with
timeval_zero().

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Cherry-pick-from: 11734be353a1e246163eda631d35dfe55d1d6fb1

11 years agoctdbd: Add an index db for message list for faster searches
Amitay Isaacs [Thu, 21 Feb 2013 02:16:15 +0000 (13:16 +1100)]
ctdbd: Add an index db for message list for faster searches

When CTDB is busy with lots of smbd, CTDB was spending too much time in
daemon_check_srvids() which searches a list of srvids in the registered
message handlers.  Using a hash based index significantly improves the
performance of search in a linked list.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Cherry-pick-from: 3e09f25d419635f6dd679b48fa65370f7860be7d

11 years agotools/ctdb: delip no longer fails if IP can not be moved
Martin Schwenke [Wed, 27 Feb 2013 05:01:55 +0000 (16:01 +1100)]
tools/ctdb: delip no longer fails if IP can not be moved

Moving the IP is an optimisation so should not cause failure.

Refactor and simplify the retry-move-IP into new function
try_moveip().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Cherry-pick-from: 5402f85dde045576cbaf64e01c68e28ed52204e8

11 years agorecoverd: Do not send "ipreallocated" event to stopped nodes
Martin Schwenke [Mon, 18 Feb 2013 05:32:14 +0000 (16:32 +1100)]
recoverd: Do not send "ipreallocated" event to stopped nodes

Stopped nodes will reject "ipreallocated" because they are in
recovery, so they will eventually be banned.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Cherry-pick-from: c270381ee81903ff459a8b23fd57c997d038cf14

11 years agoclient: New generic node listing function list_of_nodes()
Martin Schwenke [Tue, 19 Feb 2013 03:29:06 +0000 (14:29 +1100)]
client: New generic node listing function list_of_nodes()

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Cherry-pick-from: a73bb56991b8c07ed0e9517ffcf0dc264be30487

11 years agoctdbd: Remove the variable declaration shadowing earlier declaration
Amitay Isaacs [Fri, 22 Feb 2013 01:28:56 +0000 (12:28 +1100)]
ctdbd: Remove the variable declaration shadowing earlier declaration

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoctdbd: Use the correct local variable to check status
Amitay Isaacs [Fri, 22 Feb 2013 01:28:25 +0000 (12:28 +1100)]
ctdbd: Use the correct local variable to check status

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoctdbd: Fix a struct initializer
Volker Lendecke [Wed, 20 Feb 2013 09:46:47 +0000 (10:46 +0100)]
ctdbd: Fix a struct initializer

11 years agoNew Version 1.2.58 ctdb-1.2.58
Amitay Isaacs [Tue, 19 Feb 2013 07:09:05 +0000 (18:09 +1100)]
New Version 1.2.58

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoRECOVER: When we pull databases during recovery, we used to reallocate the databuffer...
Ronnie Sahlberg [Fri, 25 May 2012 02:27:59 +0000 (12:27 +1000)]
RECOVER: When we pull databases during recovery, we used to reallocate the databuffer for each entry added. This would normally not be an issue, but for cases where memory is fragmented, this could start to cost significant cpu if we need to reallocate and move to a different region.

Change this to instead preallocate , by default, 10MByte chunks to the data buffer.
This significantly reduces the number of potential reallocate and move  operations that may be required.

Create a tunable to override/change how much preallocation should be used.

Conflicts:
include/ctdb_private.h
server/ctdb_tunables.c

Cherry-pick-from: 1f262deaad0818f159f9c68330f7fec121679023

Also, make sure the preallocation size is 10MB and not 100MB.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoLogging: Free the ringbuffer in child processes created with ctdb_fork()
Martin Schwenke [Tue, 5 Feb 2013 01:09:36 +0000 (12:09 +1100)]
Logging: Free the ringbuffer in child processes created with ctdb_fork()

At the moment the log ringbuffer is duplicated in every child process.
Althought it is copy-on-write we want to see if it is contributing to
out-of-memory situations when there are a lot of children.

The ringbuffer isn't accessible from any of the children anyway...

Signed-off-by: Martin Schwenke <martin@meltin.net>
Conflicts:
common/ctdb_fork.c

Cherry-pick-from: a82d3ec12f0fda16d6bfa8442a07595de897c10e

11 years agoLogging: New function ctdb_log_ringbuffer_free()
Martin Schwenke [Tue, 5 Feb 2013 01:08:11 +0000 (12:08 +1100)]
Logging: New function ctdb_log_ringbuffer_free()

Signed-off-by: Martin Schwenke <martin@meltin.net>
Cherry-pick-from: a4f622e85168f59417c11705f1734e0352e1d44a

11 years agoeventscripts: Remove calls to "smbstatus -np" for samba cleanup
Amitay Isaacs [Mon, 11 Feb 2013 00:25:49 +0000 (11:25 +1100)]
eventscripts: Remove calls to "smbstatus -np" for samba cleanup

This is an artifact from older versions of Samba. In the newer versions of
Samba, "smbstatus -np" command does not do anything useful, but causes a
traverse in CTDB which is expensive and causes CPU utilization to shoot up.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Conflicts:
config/events.d/50.samba

Cherry-pick-from: 053b89c6dbce47001505524606889334559d2ec4

11 years agocommon/io: Rewrite socket handling code to read all available data
Amitay Isaacs [Thu, 17 Jan 2013 23:42:14 +0000 (10:42 +1100)]
common/io: Rewrite socket handling code to read all available data

This improves the processing of packets considerably.  It has been
observed that there can be as many as 10 packets in the socket buffer and
the current code of reading a single packet from a socket at a time is
not very optimal.  This change reads all the bytes from socket buffer and
then parses to extract multiple packets.  If there are multiple packets,
set up a timed event to process next packet.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Cherry-pick-from: d788bc8f7212b7dc1587ae592242dc8c876f4053

Conflicts:
common/ctdb_io.c

11 years agodaemon: Make sure all the traverse children are terminated if traverse times out
Amitay Isaacs [Tue, 22 Jan 2013 02:27:20 +0000 (13:27 +1100)]
daemon: Make sure all the traverse children are terminated if traverse times out

When traverse times out, callback function is called with key and data set to
tdb_null.  This is also the way to signal end of traverse.  So if the traverse
times out, callback function treats it as traverse ended and frees state without
calling the destructor.

Keep track if the traverse timed out, so callback function can take appropriate
action for traverse timeout and traverse end.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Cherry-pick-from: 35da9a7c2a0f5e54e61588c3c3455f06ebc66822

11 years agoNew version 1.2.57 ctdb-1.2.57
Amitay Isaacs [Wed, 6 Feb 2013 03:33:51 +0000 (14:33 +1100)]
New version 1.2.57

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoinitscript: export CTDB_DEBUG_LOCKS
Martin Schwenke [Tue, 5 Feb 2013 05:40:39 +0000 (16:40 +1100)]
initscript: export CTDB_DEBUG_LOCKS

Signed-off-by: Martin Schwenke <martin@meltin.net>
11 years agoinitscript: export CTDB_EXTERNAL_TRACE
Martin Schwenke [Tue, 5 Feb 2013 02:16:46 +0000 (13:16 +1100)]
initscript: export CTDB_EXTERNAL_TRACE

This means it can be set like any other configuration option in the
configuration file, without needing to export it there.

Cherry-pick-from: a0ef73e197dc9147f7718e0813fe803ff0b3d54d
Signed-off-by: Martin Schwenke <martin@meltin.net>
11 years agoctdbd: Backport use of external script to debug hung eventscript
Martin Schwenke [Thu, 17 May 2012 00:17:51 +0000 (10:17 +1000)]
ctdbd: Backport use of external script to debug hung eventscript

This is a cherry-pick from 6e68797af67bee36f2bad045f94806e7e98f27e9,
combined with several recent fixes:

  8507303b525d20c74e8ec4e7c4f5f275945cd3b6
    scripts: debug-hung-script.sh doesn't need functions/loadconfig
  501461cc3e132d4adee9e91b5d4513a26bae2846
    ctdbd: Remove debug_hung_script_ctx
  0581f9a84e58764d194f4e04064c2c5b393c348b
    ctdbd: Remove command-line option --debug-hung-script
  3400b2ed34b6eb9496eb55f1aab6f89d2952060d
    ctdbd: Complain loudly if CTDB_DEBUG_HUNG_SCRIPT script isn't executable
  9b0d56b16775aa16f33bdfdf831256e085fa3339
    ctdbd: Don't use a fixed length buffer for the hung script command

Signed-off-by: Martin Schwenke <martin@meltin.net>
11 years agodoc: Rebuild all documentation
Amitay Isaacs [Tue, 5 Feb 2013 01:59:53 +0000 (12:59 +1100)]
doc: Rebuild all documentation

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoDOC document the FetchCollapse tunable
Ronnie Sahlberg [Tue, 20 Mar 2012 00:38:20 +0000 (11:38 +1100)]
DOC document the FetchCollapse tunable

Cherry-pick-from: c37aa6f3738693653f64c2fa015ace061da38b5a

11 years agoFETCH COLLAPSE : Change the fetch-lock collapse to collapse ALL fetches, including...
Ronnie Sahlberg [Tue, 20 Mar 2012 00:31:59 +0000 (11:31 +1100)]
FETCH COLLAPSE : Change the fetch-lock collapse to collapse ALL fetches, including fetch-locks into a single command in flight per record. Also add a tunable to enable/disable this optimization for hot records

Conflicts:
server/ctdb_tunables.c

Cherry-pick-from: eafd7bbaaa5931546a96c8beae3cf9a39a49c925

11 years agoRecord Fetch Collapse: Collapse multiple fetch request into one single request.
Ronnie Sahlberg [Mon, 7 Nov 2011 19:55:46 +0000 (06:55 +1100)]
Record Fetch Collapse: Collapse multiple fetch request into one single request.

When multiple clients fetch the same record concurrently, send only one single
fetch across the network and deferr all other fetches locally.
This improves performance for hot records and reduces cpu load on ctdb.

Conflicts:
server/ctdb_ltdb_server.c

Cherry-pick-from: 82d6946ad8b3348e8b9d3d971f24925ade02d1be

11 years agoscripts: Fix the variable name for sed expressions
Amitay Isaacs [Wed, 9 Jan 2013 00:03:18 +0000 (11:03 +1100)]
scripts: Fix the variable name for sed expressions

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoNew version 1.2.56 ctdb-1.2.56
Amitay Isaacs [Wed, 2 Jan 2013 05:17:58 +0000 (16:17 +1100)]
New version 1.2.56

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agodaemon: Change the default recovery method for persistent databases
Amitay Isaacs [Wed, 2 Jan 2013 04:49:39 +0000 (15:49 +1100)]
daemon: Change the default recovery method for persistent databases

Use sequence numbers to do the recovery for persistent databases instead
of RSNs.  This fixes the problem of registry corrpution during recovery.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoDOC: describe the RecoverPDBBySeqNum tunable
Ronnie Sahlberg [Tue, 29 Nov 2011 21:59:03 +0000 (08:59 +1100)]
DOC: describe the RecoverPDBBySeqNum tunable

Conflicts:
doc/ctdbd.1
doc/ctdbd.1.html

Cherry-pick-from: 86d956170d4806065f1470fc44710c085c57f17a

11 years agoRecover Persistent database DB by DB and not record by record
Ronnie Sahlberg [Mon, 28 Nov 2011 02:56:30 +0000 (13:56 +1100)]
Recover Persistent database DB by DB and not record by record

Add a new tunable that changes the mode how persistent databases are recovered.
RecoveryPDBBySeqNum

When set to 1, persistent databases will be recovered in whole from the node which
has the highest "__db_sequence_number__" record.
This record is managed by samba for those databases where we do persistent writes and have
inter-record relations.
For these databases we do not want the usual "blend records from all nodes based
on individual record RSN" but instead a mode where we pick one instance of the persistent database.

If no node was found with a "__db_sequence_number__" record at all, we fail back to the original "recover records independently based on record RSN".
Some persistent databases do not contain record interrelations and as such does not
contain this special record at all.

Conflicts:
include/ctdb_private.h
server/ctdb_tunables.c

Cherry-pick-from: 502150c764298a9fa8c4d8aa445bf7d85d4ee9dc

11 years agoLibCTDB: add get persistent db seqnum control
Ronnie Sahlberg [Mon, 28 Nov 2011 05:30:46 +0000 (16:30 +1100)]
LibCTDB: add get persistent db seqnum control

Conflicts:
tools/ctdb.c

Cherry-pick-from: 6e96a62494bbb2c7b0682ebf0c2115dd2f44f7af

11 years agoDB Seqnum: must provide a ctdb_ltdb_header when calling ctdb_ltdb_fetch()
Ronnie Sahlberg [Sun, 27 Nov 2011 23:41:17 +0000 (10:41 +1100)]
DB Seqnum: must provide a ctdb_ltdb_header when calling ctdb_ltdb_fetch()

Cherry-pick-from: 1fea9ef55a6a9d201ad1b49583451ac3e6b1c66d

11 years agoscripts: Add helper script to log locking information using /proc/locks
Amitay Isaacs [Wed, 5 Dec 2012 00:38:42 +0000 (11:38 +1100)]
scripts: Add helper script to log locking information using /proc/locks

This finds any processes locking tdb databases used by CTDB and logs
stack trace for each process.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agodaemon: Run an external script if freeze locks were not obtained during recovery
Amitay Isaacs [Wed, 5 Dec 2012 00:37:26 +0000 (11:37 +1100)]
daemon: Run an external script if freeze locks were not obtained during recovery

If the freeze child is already created in ctdb_start_freeze(), then it indicates
that the child process has not yet obtained the locks.  This may be because
another process has locked the databases and has not yet released the locks.

In this case, invoke a helper script defined by environmental variable
CTDB_DEBUG_LOCKS, to log information about locks.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoNew version 1.2.55 ctdb-1.2.55
Amitay Isaacs [Tue, 27 Nov 2012 04:50:54 +0000 (15:50 +1100)]
New version 1.2.55

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoRevert "when creating/adding a public ip, set the initial interface to be the first...
Amitay Isaacs [Thu, 22 Nov 2012 03:37:45 +0000 (14:37 +1100)]
Revert "when creating/adding a public ip, set the initial interface to be the first interface specified"

This reverts commit 4308935ba48ac7a29e7523315acf580019715f0f.

When IP is added to a node on a new interface for the first time,
vnn->iface gets set to the first interface defined for that IP.  This
actually causes problem in ctdb_vnn_assign_iface().  Since vnn->iface
is set it takes an early exit without updating vnn->pnn.  This results
in IP being hosted on the node, but CTDB still thinks it's unassigned.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoEventscripts: 10.interface should list configured interfaces
Martin Schwenke [Fri, 16 Nov 2012 09:21:15 +0000 (20:21 +1100)]
Eventscripts: 10.interface should list configured interfaces

The current code lists available interfaces.  If IPs are configured in
some other way than the public addresses file (e.g. ctdb addip) and their
interfaces default to being marked down then, since down interfaces are
not available, these interfaces can never be marked up.

The configured interfaces should be listed instead.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Cherry-pick-from: d8f010355b715e49709836e057a5d0f110919897

Conflicts:
config/events.d/10.interface

11 years agoctdbd: Make the link status of new interfaces more flexible
Martin Schwenke [Fri, 16 Nov 2012 08:43:14 +0000 (19:43 +1100)]
ctdbd: Make the link status of new interfaces more flexible

Neither up nor down is a good default value for the link status of a
new interface.  Up means that IPs can be assigned to interfaces before
the true state is known and they can move away quickly if the interface
is actually down.  Down means that IPs can't be assigned to an interface
for a variable amount of time - until a monitor cycle occurs - and this
can result in imbalanced IPs.

This is a neat compromise.  Before the startup event completes, IPs
can't be assigned to interfaces because all interfaces begin in a down
state.  As soon as the startup event completes, IPs can be allocated
to any interface that has been marked up by the eventscript.  Later,
during normal operation, newly added IPs can be assigned to new
interfaces immediately.  The IPs will still move away if an interface
is noticed to be down in the next monitor cycle, but that is the
exception rather than the rule.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Cherry-pick-from: 9275a69a414482f1053ae14528d5972575b9214e

11 years agotools/ctdb: Do not use function return value as pnn
Amitay Isaacs [Tue, 6 Nov 2012 06:06:54 +0000 (17:06 +1100)]
tools/ctdb: Do not use function return value as pnn

This fixes the wrong code where same variable 'ret' is used to track the pnn
and the return value of a function call.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Cherry-pick-from: 718233c445cd6627ab3962b6565c2655f1f8efd0

11 years agorecoverd: Track the nodes that fail takeover run and set culprit count
Amitay Isaacs [Tue, 23 Oct 2012 05:23:12 +0000 (16:23 +1100)]
recoverd: Track the nodes that fail takeover run and set culprit count

If any of the nodes fail takeover run (either due to timeout or failure
to complete within takeover_timeout interval) from main loop, recovery
master will give up trying takeover run with following message:

  "Unable to setup public takeover addresses. Try again later"

And as a side-effect the monitoring is disabled on all the nodes. Before
ctdb_takeover_run() is called from main loop, monitoring get disabled via
startrecovery event. Since ctdb_takeover_run() fails, it never runs
recovered event and monitoring does not get re-enabled.

In main_loop, ctdb_takeover_run() is called with a takeover_fail_callback.
This callback will get called if any of the nodes fail in handling
takeip/releaseip/ipreallocated events in ctdb_takeover_run().

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Cherry-pick-from: a5c6bb1fffb8dc3960af113957a1fd080cc7c245

Conflicts:
include/ctdb_private.h
server/ctdb_takeover.c

11 years agodaemon: Do not ignore timed out monitor events
Amitay Isaacs [Tue, 23 Oct 2012 04:06:33 +0000 (15:06 +1100)]
daemon: Do not ignore timed out monitor events

If an eventscript times out for monitor event, it is considered successful
and the remaining eventscripts are not run. This can make a node prematurely
healthy, cause healthy node to fail over IPs to this node and this node will
not be able to host those IPs. Thus causing loss of access and in case of NAT-GW
configuration, loss of a default route.

Copy-code-from: 6e68797af67bee36f2bad045f94806e7e98f27e9

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoNew Version 1.2.54 ctdb-1.2.54
Amitay Isaacs [Tue, 30 Oct 2012 01:39:00 +0000 (12:39 +1100)]
New Version 1.2.54

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoscripts: Remove duplicate code from init script to set tunables
Amitay Isaacs [Mon, 3 Sep 2012 02:39:36 +0000 (12:39 +1000)]
scripts: Remove duplicate code from init script to set tunables

The tunable variables defined in CTDB configuration file are currently
set up from init script as well as part of "setup" event in 00.ctdb
eventscript.  Remove the duplication of this code and set tunable
variables only from setup event.  During the "setup" event, it's possible
that ctdb tool commands can timeout if CTDB daemon is not ready.  To guard
against such eventuality, wait till "ctdb ping" command succeeds before
executing any other ctdb tool commands.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Cherry-picked-from: 632c1b9c1cc2e242376358ce49fd2022b3f27aa2

Conflicts:
config/events.d/00.ctdb

11 years agodaemon: Protect against double free of callback state while shutting down
Amitay Isaacs [Mon, 29 Oct 2012 03:56:10 +0000 (14:56 +1100)]
daemon: Protect against double free of callback state while shutting down

When CTDB is shut down and monitoring has been stopped, monitor_context
gets freed and all the callback states hanging off it.  This includes
callback state for current_monitor, if the current monitor event has
not yet finished.  As a result, when the shutdown event is called,
current_monitor->callback state is not NULL, but it's actually freed
and it's a dangling reference.

So before executing callback function and freeing callback state check
if ctdb->monitor->monitor_context is not NULL.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoNew version 1.2.53 ctdb-1.2.53
Amitay Isaacs [Fri, 26 Oct 2012 05:19:35 +0000 (16:19 +1100)]
New version 1.2.53

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoInitscript - add backup of corrupt non-persistent databases
Martin Schwenke [Wed, 28 Mar 2012 03:50:36 +0000 (14:50 +1100)]
Initscript - add backup of corrupt non-persistent databases

Corrupt non-persistent databases never get analysed because ctdbd
zeroes them at startup.

Modify the initscript so that corrupt non-persistent databases are
moved aside to a backup.  If the number of backups for a particular
database exceeds $CTDB_MAX_CORRUPT_DB_BACKUPS (default 10) then the
oldest excess backups are garbage collected.

Abstracts from and cleans up the code for checking persistent
databases.

Logging of related messages is done to syslog or a log file as
specified.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Cherry-picked-from: 00cd75595685dae829758abf1a4cb644af7ed50e

Conflicts:
config/ctdb.init

11 years agoNew version 1.2.52 ctdb-1.2.52
Martin Schwenke [Fri, 5 Oct 2012 02:05:19 +0000 (12:05 +1000)]
New version 1.2.52

Signed-off-by: Martin Schwenke <martin@meltin.net>
11 years agoutil: ctdb_fork() closes all sockets opened by the main daemon
Martin Schwenke [Tue, 2 Oct 2012 01:51:24 +0000 (11:51 +1000)]
util: ctdb_fork() closes all sockets opened by the main daemon

Do some other housekeeping including stopping tevent.

Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>
11 years agoRevert "logging: Close unix socket /tmp/ctdb.socket in syslogd process"
Martin Schwenke [Tue, 2 Oct 2012 01:54:00 +0000 (11:54 +1000)]
Revert "logging: Close unix socket /tmp/ctdb.socket in syslogd process"

This reverts commit 450bedccbee3f89aba3b33777a4ae8841c456a65.

This will be fixed in ctdb_fork() for all children.  Won't somebody
PLEASE think of the children?!?

11 years agoNew version 1.2.51 ctdb-1.2.51
Amitay Isaacs [Tue, 2 Oct 2012 02:45:10 +0000 (12:45 +1000)]
New version 1.2.51

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agoLogging: Map TEVENT_DEBUG_FATAL to DEBUG_CRIT
Martin Schwenke [Thu, 27 Sep 2012 23:39:12 +0000 (09:39 +1000)]
Logging: Map TEVENT_DEBUG_FATAL to DEBUG_CRIT

This is currently mapped to DEBUG_EMERG.  CTDB really has no business
logging anything at EMERG level since the whole system is not about to
abort or catch fire.  EMERG causes the message to appear on the
console and on every terminal.  That's a bit overzealous!

There would be very few situations where logs are being filtered at
level below ERROR, so CRIT should certainly suffice.

The trigger for this was curious messages saying "No event for <n>
seconds!" logged in a user's terminal.

Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>
11 years agoEventscripts: "recovered" event should not fail on NATGW failure
Martin Schwenke [Wed, 26 Sep 2012 04:37:49 +0000 (14:37 +1000)]
Eventscripts: "recovered" event should not fail on NATGW failure

The recovery process has no protection against the "recovered" event
failing, so this can cause a recovery loop.

Instead of failing the "recovered" event, add a "monitor" event and
fail that instead.  In this case the failure semantics are well
defined.

A separate patch should ban nodes if the "recovered" event fails for
an unknown reason.

Signed-off-by: Martin Schwenke <martin@meltin.net>
11 years agoNew version 1.2.50 ctdb-1.2.50
Amitay Isaacs [Wed, 12 Sep 2012 05:02:30 +0000 (15:02 +1000)]
New version 1.2.50

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
11 years agocommon: Debug ctdb_addr_to_str() using new function ctdb_external_trace()
Martin Schwenke [Thu, 6 Sep 2012 10:22:38 +0000 (20:22 +1000)]
common: Debug ctdb_addr_to_str() using new function ctdb_external_trace()

We've seen this function report "Unknown family, 0" and then CTDB
disappeared without a trace.  If we can reproduce it then this might
help us to debug it.

The idea is that you do something like the following in /etc/sysconfig/ctdb:

  export CTDB_EXTERNAL_TRACE="/etc/ctdb/config/gcore_trace.sh"

When we hit this error than we call out to gcore to get a core file so
we can do forensics.  This might block CTDB for a few seconds.

Signed-off-by: Martin Schwenke <martin@meltin.net>
11 years agoNew version 1.2.49 ctdb-1.2.49
Martin Schwenke [Tue, 21 Aug 2012 04:35:35 +0000 (14:35 +1000)]
New version 1.2.49

Signed-off-by: Martin Schwenke <martin@meltin.net>