From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Serge Petrenko <sergepetrenko@tarantool.org>, gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v3] wal: introduce limits on simultaneous writes Date: Mon, 1 Mar 2021 23:05:26 +0100 [thread overview] Message-ID: <a2a7d894-eb5d-d2db-66fc-dc5cd3f33a7a@tarantool.org> (raw) In-Reply-To: <17046c4d-b239-f3d8-f150-941026096b1e@tarantool.org> Hi! Thanks for the fixes! >>> @@ -159,6 +276,13 @@ journal_write(struct journal_entry *entry) >>> static inline int >>> journal_write_async(struct journal_entry *entry) >>> { >>> + /* >>> + * It's the job of the caller to check whether the queue is full prior >>> + * to submitting the request. >>> + */ >>> + assert(!journal_queue_is_full() || journal_queue.is_ready); >>> + journal_queue_on_append(entry); >> 8. Probably must assert that waiters list is empty. Otherwise you >> could go out of order. > > It's not empty by the time the first entry gets to 'journal_write_async'. > Everyone else is waken up, but not yet removed from the queue. > > Looks like we cannot determine whether a write is called after waiting in queue > or not. It bothers me a lot, the rest looks good. We don't have any protection against a reorder, even not an assertion. How about this? (I didn't test): ==================== --- a/src/box/journal.c +++ b/src/box/journal.c @@ -69,8 +69,11 @@ void journal_queue_wakeup(void) { struct rlist *list = &journal_queue.waiters; - if (!rlist_empty(list) && !journal_queue_is_full()) + if (!rlist_empty(list) && !journal_queue_is_full()) { fiber_wakeup(rlist_first_entry(list, struct fiber, state)); + --journal_queue.waiter_count; + assert(journal_queue.waiter_count >= 0); + } } void @@ -84,7 +87,6 @@ journal_queue_wait(void) * Will be waken up by either queue emptying or a synchronous write. */ fiber_yield(); - --journal_queue.waiter_count; journal_queue_wakeup(); } @@ -96,5 +98,6 @@ journal_queue_flush(void) struct rlist *list = &journal_queue.waiters; while (!rlist_empty(list)) fiber_wakeup(rlist_first_entry(list, struct fiber, state)); + journal_queue.waiter_count = 0; journal_queue_wait(); } diff --git a/src/box/journal.h b/src/box/journal.h index 5f0e0accd..ea56043e2 100644 --- a/src/box/journal.h +++ b/src/box/journal.h @@ -260,6 +260,7 @@ journal_write_async(struct journal_entry *entry) * to submitting the request. */ journal_queue_on_append(entry); + assert(journal_queue.waiter_count == 0); return current_journal->write_async(current_journal, entry); }
next prev parent reply other threads:[~2021-03-01 22:05 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-24 19:35 Serge Petrenko via Tarantool-patches 2021-02-24 19:40 ` Serge Petrenko via Tarantool-patches 2021-02-25 13:05 ` Konstantin Osipov via Tarantool-patches 2021-02-26 0:57 ` Vladislav Shpilevoy via Tarantool-patches 2021-02-26 7:18 ` Konstantin Osipov via Tarantool-patches 2021-02-26 20:23 ` Vladislav Shpilevoy via Tarantool-patches 2021-02-26 21:20 ` Konstantin Osipov via Tarantool-patches 2021-02-26 22:44 ` Vladislav Shpilevoy via Tarantool-patches 2021-02-27 13:27 ` Konstantin Osipov via Tarantool-patches 2021-03-01 19:15 ` Serge Petrenko via Tarantool-patches 2021-03-01 21:46 ` Konstantin Osipov via Tarantool-patches 2021-02-26 0:56 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-01 19:08 ` Serge Petrenko via Tarantool-patches 2021-03-01 22:05 ` Vladislav Shpilevoy via Tarantool-patches [this message] 2021-03-02 17:51 ` Serge Petrenko via Tarantool-patches 2021-03-03 20:59 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-09 15:10 ` Serge Petrenko via Tarantool-patches 2021-03-09 19:49 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-10 8:18 ` Konstantin Osipov via Tarantool-patches 2021-03-12 17:10 ` Serge Petrenko via Tarantool-patches 2021-03-13 19:14 ` Konstantin Osipov via Tarantool-patches 2021-03-15 23:42 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-16 6:45 ` Konstantin Osipov via Tarantool-patches 2021-03-16 20:27 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-16 10:19 ` Serge Petrenko via Tarantool-patches 2021-03-16 20:48 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-17 12:14 ` Serge Petrenko via Tarantool-patches 2021-03-17 21:02 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-19 11:32 ` Serge Petrenko via Tarantool-patches 2021-03-19 15:36 ` Kirill Yukhin via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=a2a7d894-eb5d-d2db-66fc-dc5cd3f33a7a@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=gorcunov@gmail.com \ --cc=sergepetrenko@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v3] wal: introduce limits on simultaneous writes' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox