summaryrefslogtreecommitdiff
path: root/source3/torture/test_dbwrap_watch.c
Commit message (Collapse)AuthorAgeFilesLines
* s3:dbwrap_watch: allow callers of dbwrap_watched_watch_send/recv() to manage ↵Stefan Metzmacher2022-07-261-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the watcher instances The destructor triggered by dbwrap_watched_watch_recv() will remove the watcher instance via a dedicated dbwrap_do_locked(), just calling dbwrap_watched_watch_remove_instance() inside. But the typical caller triggers a dbwrap_do_locked() again after dbwrap_watched_watch_recv() returned. Which means we call dbwrap_do_locked() twice. We now allow dbwrap_watched_watch_recv() to return the existing instance id (if it still exists) and removes the destructor. That way the caller can pass the given instance id to dbwrap_watched_watch_remove_instance() from within its own dbwrap_do_locked(), when it decides to leave the queue, because it's happy with the new state of the record. In order to get the best performance dbwrap_watched_watch_remove_instance() should be called before any dbwrap_record_storev() or dbwrap_record_delete(), because that will only trigger a single low level storev/delete. If the caller found out that the state of the record doesn't meet the expectations and the callers wants to continue watching the record (from its current position, most likely the first one), dbwrap_watched_watch_remove_instance() can be skipped and the instance id can be passed to dbwrap_watched_watch_send() again, in order to resume waiting on the existing instance. Currently the watcher instance were always removed (most likely from the first position) and re-added (to the last position), which may cause unfair latencies. In order to improve the overhead of adding a new watcher instance the caller can call dbwrap_watched_watch_add_instance() before any dbwrap_record_storev() or dbwrap_record_delete(), which will only result in a single low level storev/delete. The returned instance id is then passed to dbwrap_watched_watch_send(), within the same dbwrap_do_locked() run. It also adds a way to avoid alerting any callers during the current dbwrap_do_locked() run. Layers above may only want to wake up watchers during specific situations and while it's useless to wake others in other situations. This will soon be used to add more fairness to the g_lock code. Note that this commit only prepares the api for the above to be useful, the instance returned by dbwrap_watched_watch_recv() is most likely 0, which means the watcher entry was already removed, but that will change in the following commits. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* torture3: Test the next patch: No two waiters in one do_locked()Volker Lendecke2019-11-221-0/+167
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* torture3: Consolidate dbwrap_watch test initializationVolker Lendecke2019-11-221-55/+74
| | | | | | | More lines, but less error-prone copy&paste Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap_watch: Test cleanup of dead watchersVolker Lendecke2019-10-181-0/+103
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Clarify db_open_watched APIVolker Lendecke2018-08-171-2/+2
| | | | | | | | | | | Point out in the API that "backend" talloc_moves into the watched database. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Aug 17 21:29:15 CEST 2018 on sn-devel-144
* dbwrap_watch: Remove the "prec" parameter from watch_recvVolker Lendecke2017-11-291-2/+1
| | | | | | | | | | | The initial idea was to have some "atomicity" in this API. Every caller interested in a record would have to do something with it once it changes. However, only one caller really used this feature, and that is easily changed to not use it. So remove the complexity. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* torture3: Make sure dbwrap_parse_record returns NOT_FOUND for invalid ↵Volker Lendecke2017-05-011-0/+68
| | | | | | | | | | watchers data Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Mon May 1 14:39:41 CEST 2017 on sn-devel-144
* torture3: In LOCAL-DBWRAP-WATCH1, open tdb with CLEAR_IF_FIRSTVolker Lendecke2017-05-011-1/+2
| | | | | | | | | Also ensure we delete the temp tdb file on success. Just make sure we start with fresh data Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Jeremy Allison <jra@samba.org>
* dbwrap: Add an alternative implementation of dbwrap_watch_record_sendVolker Lendecke2016-07-151-9/+12
| | | | | | | | | | | | | | | The existing one with a separate dbwrap_watchers.tdb turns out to create a performance penalty in a clustered environment. Non-clustered, dbwrap_parse_record on non-existent records is very cheap, but in a cluster environment this is very noticable. This implementation puts the watcher information into the records itself. For large records, this might be another performance penalty, because we have to assemble the final record together with talloc and memcpy, but this might be fixed later with a tdb_storev call. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Add "blocker" to record_watch_sendVolker Lendecke2016-07-151-2/+4
| | | | | | | | | | Typicall, when we watch a record, we wait for a process to give up some resource. Be it an oplock, a share mode or the g_lock. If everything goes well, the blocker sends us a message. If the blocker dies hard, we want to also be informed immediately. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* torture3: Add a bit more coverage to messaging_readVolker Lendecke2014-04-301-0/+7
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: add a dbwrap_flags argument to db_open()Michael Adam2014-02-071-1/+2
| | | | | | | | | | 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>
* s3:torture: make use of samba_tevent_context_init()Stefan Metzmacher2013-02-191-1/+1
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* dbwrap: dbwrap_store_int32->dbwrap_store_int32_bystringVolker Lendecke2012-06-151-1/+1
| | | | Signed-off-by: Michael Adam <obnox@samba.org>
* s3-dbwrap: Add dbwrap_record_watch_send/recvVolker Lendecke2012-04-191-0/+96
With this API you can asynchronously wait for a record to be modified