summaryrefslogtreecommitdiff
path: root/ctdb/client
Commit message (Collapse)AuthorAgeFilesLines
* ctdb-client: Drop client code for global transaction controlsAmitay Isaacs2016-07-282-106/+0
| | | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Remove code to set/get_db_priority from new client codeAmitay Isaacs2016-07-252-72/+0
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Remove client code for set/get_db_priorityAmitay Isaacs2016-07-251-53/+0
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Remove ctdb_ctrl_freeze_priority() functionAmitay Isaacs2016-07-251-20/+4
| | | | | | | | ctdb_ctrl_freeze() now only needs to send a single control since there are no database priorities any more. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Mark ctdb_ctrl_freeze_priority staticAmitay Isaacs2016-07-251-3/+3
| | | | | | | It is not used outside ctdb_client.c Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Drop unused functions ctdb_ctrl_freeze_send/recvAmitay Isaacs2016-07-251-29/+0
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Reimplement ctdb_ctrl_freeze_priority() using ctdb_control()Amitay Isaacs2016-07-251-7/+12
| | | | | | | This makes it easier to drop unused async implementation of the same. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Remove function ctdb_ctrl_thaw() from new client APIAmitay Isaacs2016-07-252-34/+0
| | | | | | | This function is not used anywhere. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Remove functions ctdb_ctrl_thaw_priority() and ctdb_ctrl_thaw()Amitay Isaacs2016-07-251-25/+0
| | | | | | | These functions are not used anywhere. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Fix access after free errorMartin Schwenke2016-07-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | State is stolen onto tmp_ctx above so can't be referenced after tmp_ctx is freed. So, state->status has to be looked at earlier. Moving it immediately before the talloc_free(tmp_ctx) isn't sufficient because invoking the callback appears to cause a recursive call to ctdb_control_recv(), which also frees state. Referencing it at the top seems safe. ==23982== Invalid read of size 4 ==23982== at 0x4204AE: ctdb_control_recv (ctdb_client.c:1181) ==23982== by 0x420645: invoke_control_callback (ctdb_client.c:971) ==23982== by 0x5E675EC: tevent_common_loop_timer_delay (tevent_timed.c:341) ==23982== by 0x5E68639: epoll_event_loop_once (tevent_epoll.c:911) ==23982== by 0x5E66BD6: std_event_loop_once (tevent_standard.c:114) ==23982== by 0x5E622EC: _tevent_loop_once (tevent.c:533) ==23982== by 0x4255F7: ctdb_client_async_wait (ctdb_client.c:3385) ==23982== by 0x42578A: ctdb_client_async_control (ctdb_client.c:3442) ==23982== by 0x41B405: ctdb_get_nodes_files (ctdb.c:5488) ==23982== by 0x41B405: check_all_node_files_are_identical (ctdb.c:5530) ==23982== by 0x41B405: control_reload_nodes_file (ctdb.c:5673) ==23982== by 0x404DBA: main (ctdb.c:6008) ==23982== Address 0x7e98d9c is 108 bytes inside a block of size 168 free'd ==23982== at 0x4C2CDFB: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==23982== by 0x5652692: _tc_free_internal (talloc.c:1125) ==23982== by 0x5652692: _tc_free_children_internal (talloc.c:1570) ==23982== by 0x564B952: _tc_free_internal (talloc.c:1081) ==23982== by 0x564B952: _talloc_free_internal (talloc.c:1151) ==23982== by 0x564B952: _talloc_free (talloc.c:1693) ==23982== by 0x4204C9: ctdb_control_recv (ctdb_client.c:1182) ==23982== by 0x4207AA: async_callback (ctdb_client.c:3350) ==23982== by 0x4204AD: ctdb_control_recv (ctdb_client.c:1179) ==23982== by 0x420645: invoke_control_callback (ctdb_client.c:971) ==23982== by 0x5E675EC: tevent_common_loop_timer_delay (tevent_timed.c:341) ==23982== by 0x5E68639: epoll_event_loop_once (tevent_epoll.c:911) ==23982== by 0x5E66BD6: std_event_loop_once (tevent_standard.c:114) ==23982== by 0x5E622EC: _tevent_loop_once (tevent.c:533) ==23982== by 0x4255F7: ctdb_client_async_wait (ctdb_client.c:3385) ==23982== Block was alloc'd at ==23982== at 0x4C2BBCF: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==23982== by 0x564DBEC: __talloc_with_prefix (talloc.c:675) ==23982== by 0x564DBEC: __talloc (talloc.c:716) ==23982== by 0x564DBEC: _talloc_named_const (talloc.c:873) ==23982== by 0x564DBEC: _talloc_zero (talloc.c:2318) ==23982== by 0x42017F: ctdb_control_send (ctdb_client.c:1086) ==23982== by 0x425746: ctdb_client_async_control (ctdb_client.c:3431) ==23982== by 0x41B405: ctdb_get_nodes_files (ctdb.c:5488) ==23982== by 0x41B405: check_all_node_files_are_identical (ctdb.c:5530) ==23982== by 0x41B405: control_reload_nodes_file (ctdb.c:5673) ==23982== by 0x404DBA: main (ctdb.c:6008) ==23982== Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* ctdb-client: Fix incorrect variable referenceMartin Schwenke2016-07-201-1/+1
| | | | | | | | | The point of this code is almost certainly to return non-zero when state->errormsg is set. So, return state->status if non-zero, -1 otherwise. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* ctdb-client: Expose ctdb_ltdb_fetch in client APIAmitay Isaacs2016-07-052-3/+7
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Add debug messages to client db apiAmitay Isaacs2016-07-051-12/+106
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Fix implementation of transaction cancelAmitay Isaacs2016-07-051-1/+27
| | | | | | | | Wrap async transaction cancel to unlock g_lock lock and free transaction handle. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Add async version of transaction cancelAmitay Isaacs2016-07-052-0/+81
| | | | | | | Transaction cancel should get rid of g_lock lock. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Fix implementation of transaction commitAmitay Isaacs2016-07-052-57/+75
| | | | | | | | | | | | | There is no need to explicitly check that recovery is not active before sending TRANS33_COMMIT control. Just try TRANS3_COMMIT control and if recovery occurs before the control is completed, the control will fail and it can be retried. Make sure g_lock lock is released after the transaction is complete. Also, add timeout to the client api. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Fix implementation of transaction startAmitay Isaacs2016-07-051-53/+2
| | | | | | | | | | | | | | | | | Since g_lock checks if the process exists in case of conflicting lock, there is no need to register srvid. Transaction start returns a transaction handle and transaction commit/cancel will free that handle. Since we cannot call async code in a talloc destructor, this avoids the use of talloc destructor for cancelling the transaction. If user frees the transaction handle instead of calling transaction cancel, it will leave stale g_lock lock. This stale g_lock lock will get cleaned up on next transaction attempt. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: During transaction commit fetch seqnum locallyAmitay Isaacs2016-07-051-74/+51
| | | | | | | This avoids extra controls to the server. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Release the g_lock record once the update is doneAmitay Isaacs2016-07-051-0/+3
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Remove commented old g_lock implemention codeAmitay Isaacs2016-07-051-77/+0
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Release g_lock lock before retryingAmitay Isaacs2016-07-051-0/+1
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Fix g_lock implementationAmitay Isaacs2016-07-051-21/+7
| | | | | | | | If a conflicting g_lock entry is found, check if the process exists. This matches Samba implementation. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: If g_lock lock conflicts, try again soonerAmitay Isaacs2016-07-051-1/+1
| | | | | | | | Instead of delaying for 1 second, try to get g_lock lock again after 1 milli-second. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Factor out ctdb_client_get_server_id functionAmitay Isaacs2016-07-053-7/+22
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Use async version of delete_record in g_lock unlockAmitay Isaacs2016-07-051-3/+33
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Fix implementation of delete_recordAmitay Isaacs2016-07-051-28/+14
| | | | | | | | In delete_record, sync call to ctdb_ctrl_schedule_for_deletion will cause nested event loops. Instead wrap the async version. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Add async version of delete_recordAmitay Isaacs2016-07-052-0/+108
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Fix ctdb_rec_buffer traversal routineAmitay Isaacs2016-07-051-6/+13
| | | | | | | | | In commit 1ee7053180057ea526870182b5619a206b4d103b, the ctdb_rec_buffer_traverse always passes NULL for header. So explicitly extract header from the data. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Add sync version of sending multiple messagesAmitay Isaacs2016-07-052-0/+35
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-daemon: Use lib/util functions instead of redefinitionsAmitay Isaacs2016-06-081-2/+2
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Remove support for SET_RECLOCKMartin Schwenke2016-06-083-62/+0
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-protocol: Return required buffer size in push functionsAmitay Isaacs2016-05-033-3/+3
| | | | | | | | If the buffer size provided is not sufficient, then return the required buffer length. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Drop unnecessary discard_constAmitay Isaacs2016-05-031-1/+1
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-protocol: Drop buffer allocation from protocol push functionsAmitay Isaacs2016-05-033-6/+27
| | | | | | | | This means that the packet allocation will happen just before push functions are called. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Use correct TDB flags for opening databaseAmitay Isaacs2016-04-241-7/+8
| | | | | | | | | | | | Persistent: TDB_DEFAULT Volatile: TDB_NOSYNC | TDB_INCOMPATIBLE_HASH | TDB_CLEAR_IF_FIRST | TDB_MUTEX_LOCKING (if TDBMutexEnabled is set) Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Sun Apr 24 03:25:27 CEST 2016 on sn-devel-144
* ctdb-client: Set control opcode in reply for one-way controlsAmitay Isaacs2016-04-231-0/+1
| | | | | | | | | Some controls are fire-and-forget (CTDB_CTRL_FLAG_NOREPLY). Since there is no reply received, the opcode in the ctdb_reply_control structure never gets set. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Remove client functions related to server_idAmitay Isaacs2016-04-233-280/+4
| | | | | | | | | These functions were used in the transaction code. These controls did not use server_id structure defined in samba, so samba would not use them. Instead check if the process exists for conflicting g_lock entry. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Drop killtcp client functionsMartin Schwenke2016-04-013-59/+0
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-client: Add client API functions for new controlsAmitay Isaacs2016-03-252-0/+101
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Add client API for sending message to multiple nodesAmitay Isaacs2016-03-252-0/+142
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Increase the timeout for TRANS3_COMMIT controlAmitay Isaacs2016-03-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | On a busy system, TRANS3_COMMIT control can take upto or longer than 3 seconds. On timeout, there are few possible outcomes. 1. The transaction has completed on all nodes and TRANS3_COMMIT control has returned. In such a case, there is no problem. 2. The transaction has completed on the local node, but TRANS3_COMMIT control is still active. In such a case, ctdb_transaction_commit() can return successfully. If this is being called from ctdb, then ctdb will exit. This will cause ctdb daemon to trigger recovery since the client exited while transaction is active. This will cause unnecessary recovery. 3. Database recovery was started and ctdb_transaction_commit() will retry till the recovery completes the transaction. Increasing the timeout to 30 seconds will avoid the spurious database recoveries when TRANS3_COMMIT control takes longer to finish. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Fri Mar 11 19:59:53 CET 2016 on sn-devel-144
* ctdb: Drop unnecessary defines of TEVENT_DEPRECATEDMartin Schwenke2016-02-261-2/+0
| | | | | | | | | | | | | These have been scattered around the code so that tevent_loop_allow_nesting() can be called. However, only the main daemon and some tests currently use nested event loops. TEVENT_DEPRECATED is already defined in the places where it is needed. 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): Fri Feb 26 07:11:29 CET 2016 on sn-devel-144
* ctdb-client: Add missing initialisation of calldataAmitay Isaacs2016-02-241-0/+1
| | | | | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Wed Feb 24 11:57:23 CET 2016 on sn-devel-144
* ctdb-client: Keep trying to migrate till record lock is obtainedAmitay Isaacs2016-02-241-1/+3
| | | | | | | | | If a record is not on a local node, then it is migrated from remote node. However, before the client can get a lock on the record, it's possible for the record to get migrated away. In that case, repeat migration. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Remove TALLOC_CTX argument from sync functionsAmitay Isaacs2016-02-242-8/+18
| | | | | | | There is no allocated memory returned from these functions. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Add async version of set/remove message handler functionsAmitay Isaacs2016-02-242-0/+197
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Add sync API for waiting for recoveryAmitay Isaacs2016-02-242-0/+28
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Drop TALLOC_CTX argument from ctdb_attachAmitay Isaacs2016-02-242-2/+11
| | | | | | | | The database context returned is allocated off the client and is not allocated from user-supplied TALLOC_CTX. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Add new API for ctdb_client_wait_timeout()Amitay Isaacs2016-02-242-0/+46
| | | | | | | This is similar to ctdb_client_wait() with additional timeout argument. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Do not use sync functions in async computationAmitay Isaacs2016-02-241-21/+71
| | | | | | | This leads to nested event loops. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>