summaryrefslogtreecommitdiffstats
path: root/source3/lib/dbwrap
Commit message (Collapse)AuthorAgeFilesLines
* dbwrap_ctdb: open locally with TDB_VOLATILE if requestedVolker Lendecke2014-05-241-1/+1
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* dbwrap_tdb: Use mutexes on demandVolker Lendecke2014-05-221-0/+19
| | | | | | | | Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Use messaging_filtered_readVolker Lendecke2014-05-081-21/+21
| | | | | | | | | | This does not really save any code lines, but IMHO the code is simpler this way. Also, in case we have lots of watchers this will be slightly cheaper, because we don't have to re-establish a tevent_req. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb_wrap: Remove tdb_wrap_open_ againVolker Lendecke2014-03-311-3/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Avoid passing lp_ctx to tdb_wrap_open in db_open_ctdbVolker Lendecke2014-03-311-2/+7
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:build: remove global CLUSTER_SUPPORT defineStefan Metzmacher2014-03-241-7/+1
| | | | | | | | | | All ctdb specific code is isolated in samba-cluster-support.so now. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Mon Mar 24 19:08:44 CET 2014 on sn-devel-104
* s3:wscript: only build ctdb_dummy.c if we have no cluster supportStefan Metzmacher2014-03-241-4/+0
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3:param: move lp_ctdbd_socket() to ctdbd_conn.cStefan Metzmacher2014-03-241-3/+1
| | | | | | | This allows us to use CTDB_PATH only in ctdbd_conn.c Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3:lib: move all ctdb related dummy functions to ctdb_dummy.cStefan Metzmacher2014-03-241-14/+0
| | | | | | | This gets all dummy functions for the build without CLUSTER_SUPPORT. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* dbwrap_ctdb: avoid smbd/ctdb deadlocks: check whether we can work locally in ↵Michael Adam2014-03-031-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | db_ctdb_parse_record() If the same process tries to re-lock the same record it has already locked, don't go to the ctdbd again. There are situations where we already have a lock on a record and then do a dbwrap_parse_record() on that record, for instance in locking code: do_lock() -> grabs lock on brl record with brl_get_locks() -> calls brl_lock() -> calls brl_lock_posix or _windows_default() -> calls contend_level2_oplocks_begin() -> calls brl_locks_get_read_only() -> calls dbwrap_parse_record on the same brl record as above In the local (tdb) case, this is not a problem, because identical fcntl locks in the same process don't contend each other, but calling out to ctdb for this lets smbd and ctdb deadlock. db_ctdb_fetch_lock() already correclty checks first whether we can simply try to lock locally. But db_ctdb_parse_record() failed to do so for empty records, i.e. records that only consist of the ctdb record header. (These can be deleted records but can also be freshly created and still empty records.) This patch lets db_ctdb_parse_record() not skip local access for empty records, hence fixing the deadlock. PLAN: In the long run, it would be better to solve this generically on the dbwrap_layer, i.e. root the notion of an already locked record there, and skip any call to the db (tdb or ctdb backend) if we have it. This would also solve the problem for all calls like fetch_locked, parse_record and possibly others. But this is the urgent fix for now. Pair-Programmed-With: Volker Lendecke <vl@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Tested-by: Björn Baumbach <bb@sernet.de>
* dbwrap: Slightly simplify dbwrap_watch_record_storedVolker Lendecke2014-02-251-5/+2
| | | | | | | | | | | We have messaging_send_buf, so there's no point to use an explicit DATA_BLOB here. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Feb 25 23:27:21 CET 2014 on sn-devel-104
* dbwrap: use DBWRAP_LOCK_ORDER_VALID() in db_open()Michael Adam2014-02-071-9/+1
| | | | | | | | | | instead of the hand written test. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Fri Feb 7 18:05:51 CET 2014 on sn-devel-104
* dbwrap: add dbwrap_flags argument to dbwrap_local_open()Michael Adam2014-02-071-1/+1
| | | | | | | | To be consistent with db_open() and prepare for future possible extensions. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* dbwrap_open: add 'dbwrap_optimize_readonly:* = yes' optionStefan Metzmacher2014-02-071-0/+25
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* dbwrap_ctdb: implement DBWRAP_FLAG_OPTIMIZE_READONLY_ACCESSStefan Metzmacher2014-02-071-0/+21
| | | | | | | | | | For non-persistent databases we try to use CTDB_CONTROL_SET_DB_READONLY in order to make use of readonly records. Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org>
* dbwrap: add a dbwrap_flags argument to db_open_ctdb()Michael Adam2014-02-073-4/+7
| | | | | | | | This is in preparation of directly supporting ctdb read only record copies when opening a ctdb database from samba. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* dbwrap: add a dbwrap_flags argument to db_open()Michael Adam2014-02-073-3/+6
| | | | | | | | | | This is in preparation to support handing flags to backends, in particular activating read only record support for ctdb databases. For a start, this does nothing but adding the parameter, and all databases use DBWRAP_FLAG_NONE. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* dbwrap_watch: Use messaging_read_send/recvVolker Lendecke2014-01-211-13/+7
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Add messaging_read_send/recvVolker Lendecke2014-01-211-1/+0
| | | | | | | | | | | | | | | | | | | This is made to replace the msg_channel abstraction. msg_channel was created to not miss any messages. For this, some complex queueing was installed. This complexity has caused quite a few problems in the past (see bug 10284 for example). messaging_read_send/recv is able to achieve the same goal with a lot less complexity. The messaging_read_send atomically installs the reader into the messaging_context, we will not miss any messages while this installed. messaging_send_recv will deinstall that listener, but in the callback function you can directly call messaging_read_send again without going through the tevent_loop_once. As long as this is always made sure, no messages will be lost. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:dbwrap: Use milliseconds for "Held tdb lock" messageChristof Schmitt2014-01-161-5/+6
| | | | | | | | | | | This is consistent with the parameter using milliseconds and the other warnings in the same file also using milliseconds. Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Thu Jan 16 11:19:39 CET 2014 on sn-devel-104
* s3:dbwrap: Store warning thresholds in db_ctdb_ctxChristof Schmitt2014-01-161-4/+18
| | | | | | | | | Avoid the parameter lookup for the warning thresholds in the hot code path by reading them in db_open_ctdb and storing them in the db_ctdb_ctx. Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3:dbwrap include the hashchain in the logsChristian Ambach2014-01-161-3/+12
| | | | | | Signed-off-by: Christian Ambach <ambi@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3:dbwrap report time for chainlock and CTDB migrateChristian Ambach2014-01-161-2/+15
| | | | | | Signed-off-by: Christian Ambach <ambi@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* dbwrap_ctdb: Instrument chainunlock timingVolker Lendecke2014-01-161-2/+26
| | | | | | | | | | | | We need an indication whether we run into the fcntl thundering herd. fcntl unlock should be blindingly fast in the normal case. If it takes longer than 5 milliseconds, warn. The timeout can be adapted by setting ctdb:unlock_warn_threshold = <number-of-milliseconds> Reviewed-by: Christof Schmitt <cs@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org>
* ctdb_conn: Log long fetch_lock callsVolker Lendecke2014-01-161-4/+22
| | | | | | | | | | | | | | | | | With this patch, the number of fetch_lock attempts before dbwrap_ctdb logs that it took x attempts to get a record is configurable with net conf setparm global ctdb:migrate_attempts 10 This patch also adds net conf setparm global ctdb:migrate_duration 5000 to trigger the same log message if it took longer than x milliseconds to retrieve a record. Reviewed-by: Christof Schmitt <cs@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org>
* dbwrap_ctdb: Treat empty records as non-existingVolker Lendecke2013-08-281-0/+10
| | | | | | | | | This is a patch implementing the workaround Christian mentioned in https://bugzilla.samba.org/show_bug.cgi?id=10008#c5 Bug: https://bugzilla.samba.org/show_bug.cgi?id=10008 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
* s3:lib/dbwrap add missing curly bracesChristian Ambach2013-05-161-2/+4
| | | | | | | | violation of README.Coding Signed-off-by: Christian Ambach <ambi@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* dbwrap: Allow dbwrap_record_watch_recv to not lock the recordVolker Lendecke2013-04-261-0/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap-ctdb: Avoid a talloc_stackframe()Volker Lendecke2013-03-261-4/+2
| | | | | | | | We have only a single allocation in this routine, so I think we can live without a stackframe. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* dbwrap-ctdb: Use ctdbd_parse in db_ctdb_parse_recordVolker Lendecke2013-03-261-9/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* dbwrap: Use tdb_null in db_ctdb_deleteVolker Lendecke2013-03-251-4/+1
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org> Autobuild-User(master): Christian Ambach <ambi@samba.org> Autobuild-Date(master): Mon Mar 25 19:42:30 CET 2013 on sn-devel-104
* s3:dbrwap_ctdb: ZERO_STRUCT(rec) just to be sure in ↵Michael Adam2013-02-041-0/+1
| | | | | | | traverse_persistent_callback_read() Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:dbwrap_ctdb: ZERO_STRUCT(rec) just to be sure in traverse_read_callback()Michael Adam2013-02-041-0/+2
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:dbwrap_ctdb: add "db_context" to "db_record"Stefan Metzmacher2013-02-041-2/+5
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3:dbwrap_ctdb: setup result->name in db_open_ctdb()Stefan Metzmacher2013-02-041-0/+7
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* dbwrap: Use INCOMPATIBLE_HASH for dbwrap_watchers.tdbVolker Lendecke2013-01-111-3/+4
| | | | Reviewed-by: Stefan Metzmacher <metze@samba.org>
* dbwrap: Do not rely on dbwrap_record_get_value to return a talloc objectVolker Lendecke2012-11-291-2/+3
| | | | | | | | | | | db_tdb_fetch_locked returns the value as part of a larger talloc object that also contains the key. This means we can not realloc, but have to freshly alloc. Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Thu Nov 29 20:21:51 CET 2012 on sn-devel-104
* s3: Remove db_ctdb_fetchVolker Lendecke2012-11-291-55/+11
| | | | | | | Note that this also makes the request for read only copies much more explicity visible in the code. Reviewed-by: Michael Adam <obnox@samba.org>
* s3: Directly parse local existing records in db_ctdb_parse_recordVolker Lendecke2012-11-291-0/+22
| | | | Reviewed-by: Michael Adam <obnox@samba.org>
* s3: Factor out db_ctdb_can_use_local_hdr from db_ctdb_can_use_local_copyVolker Lendecke2012-11-291-11/+14
| | | | Reviewed-by: Michael Adam <obnox@samba.org>
* s3: Remove unused code for fetching persistent ctdb recordsVolker Lendecke2012-11-291-129/+0
| | | | | | | The only entry point here is parse_record, and this catches the persistent case with a direct parse now Reviewed-by: Michael Adam <obnox@samba.org>
* s3: Avoid db_ctdb_fetch for persistent databasesVolker Lendecke2012-11-291-0/+44
| | | | Reviewed-by: Michael Adam <obnox@samba.org>
* s3: Factor out parse_newest_in_marshall_buffer from ↵Volker Lendecke2012-11-291-15/+51
| | | | | | pull_newest_from_marshall_buffer Reviewed-by: Michael Adam <obnox@samba.org>
* s3: reduce db_ctdb_marshall_loop_next to specialized db_ctdb_marshall_buf_parseVolker Lendecke2012-11-291-48/+21
| | | | | | now that the db_ctdb_marshall_loop_next_key has been factored out. Reviewed-by: Michael Adam <obnox@samba.org>
* s3: Factor out db_ctdb_marshall_loop_next_key from db_ctdb_marshall_loop_nextVolker Lendecke2012-11-291-9/+24
| | | | Reviewed-by: Michael Adam <obnox@samba.org>
* s3: Slightly simplify db_ctdb_marshall_loop_nextVolker Lendecke2012-11-291-4/+3
| | | | | | Both callers give a key argument Reviewed-by: Michael Adam <obnox@samba.org>
* s3: Use db_ctdb_ltdb_parse in db_ctdb_fetch_db_seqnum_from_dbVolker Lendecke2012-11-291-20/+21
| | | | Reviewed-by: Michael Adam <obnox@samba.org>
* s3: Use db_ctdb_ltdb_parse in db_ctdb_ltdb_fetchVolker Lendecke2012-11-291-30/+46
| | | | Reviewed-by: Michael Adam <obnox@samba.org>
* s3: Add db_ctdb_ltdb_parseVolker Lendecke2012-11-291-0/+42
| | | | Reviewed-by: Michael Adam <obnox@samba.org>
* s3: Slightly simplify db_ctdb_transaction_commitVolker Lendecke2012-11-291-1/+2
| | | | | | Avoid an unnecessary "else". Reviewed-by: Michael Adam <obnox@samba.org>