1. 23 Apr, 2021 1 commit
  2. 22 Apr, 2021 7 commits
  3. 21 Apr, 2021 11 commits
    • Martin Blix Grydeland's avatar
      Allow EXP_Remove() to be called before EXP_Insert() · c9e52f94
      Martin Blix Grydeland authored
      Once HSH_Unbusy() has been called there is a possibility for
      EXP_Remove() to be called before the fetch thread has had a chance to call
      EXP_Insert(). By adding a OC_EF_NEW flag on the objects during
      HSH_Unbusy(), that is removed again during EXP_Insert(), we can keep track
      and clean up once EXP_Insert() is called by the inserting thread if
      EXP_Remove() was called in the mean time.
      
      This patch also removes the AZ(OC_F_DYING) in EXP_Insert(), as that is no
      longer a requirement.
      
      Fixes: #2999
      c9e52f94
    • Martin Blix Grydeland's avatar
      Execute EXP_Insert after unbusy in HSH_Insert · 039f6580
      Martin Blix Grydeland authored
      This makes the order of events the same as on real cache insertions.
      039f6580
    • Martin Blix Grydeland's avatar
      Repurpose OC_EF_REFD flag slightly · 0988d5f3
      Martin Blix Grydeland authored
      The OC_EF_REFD flag indicates whether expiry has a ref on the
      OC. Previously, the flag was only gained during the call to
      EXP_Insert. With this patch, and the helper function EXP_RefNewObjcore(),
      the flag is gained while holding the objhead mutex during
      HSH_Unbusy(). This enables the expiry functions to test on missing
      OC_EF_REFD and quickly return without having to take the main expiry
      mutex.
      
       Conflicts:
      	bin/varnishd/cache/cache_varnishd.h
      0988d5f3
    • Martin Blix Grydeland's avatar
      Only count exp_mailed events when actually posting · a12a65c3
      Martin Blix Grydeland authored
      When posting to the expiry thread, we wrongly counted exp_mailed also if
      the OC in question was already on the mail queue. This could cause a
      discrepency between the exp_mailed and exp_received counters.
      a12a65c3
    • Martin Blix Grydeland's avatar
      Move the locking calls outside exp_mail_it · 3f048b83
      Martin Blix Grydeland authored
      This enables doing extra handling while holding the mutex specific to
      EXP_Insert/EXP_Remove before/after calling exp_mail_it.
      3f048b83
    • Nils Goroll's avatar
      properly maintain the obans list when pruning the ban list tail · 88c2b20a
      Nils Goroll authored
      background: When the ban lurker has finished working the bottom of the
      ban list, conceptually we mark all bans it has evaluated as completed
      and then remove the tail of the ban list which has no references any
      more.
      
      Yet, for efficiency, we first remove the tail and then mark only those
      bans completed, which we did not remove. Doing so depends on knowing
      where in the (obans) list of bans to be completed is the new tail of
      the bans list after pruning.
      
      5dd54f83 was intended to solve this,
      but the fix was incomplete (and also unnecessarily complicated): For
      example when a duplicate ban was issued, ban_lurker_test_ban() could
      remove a ban from the obans list which later happens to become the new
      ban tail.
      
      We now - hopefully - solve the problem for real by properly cleaning
      the obans list when we prune the ban list.
      
      Fixes #3006
      Fixes #2779
      Fixes #2556 for real (5dd54f83 was
      incomplete)
      
       Conflicts:
      	bin/varnishd/cache/cache_ban_lurker.c
      88c2b20a
    • Martin Blix Grydeland's avatar
      Limit watchdog to highest priority only · 44437837
      Martin Blix Grydeland authored
      The watchdog mechanism currently triggers when any queueing is happening,
      regardless of the priority. Strictly speaking it is only the backend
      fetches that are critical to get executed, and this prevents the thread
      limits to be used as limits on the amount of work the Varnish instance
      should handle.
      
      This can be especially important for instances with H/2 enabled, as these
      connections will be holding threads for extended periods of time, possibly
      triggering the watchdog in benign situations.
      
      This patch limits the watchdog to only trigger for no queue development
      on the highest priority queue.
      44437837
    • Martin Blix Grydeland's avatar
      Use the REQ priority for incoming connection tasks by the acceptor · 42267902
      Martin Blix Grydeland authored
      When accepting new incoming connections in the acceptor thread, it would
      schedule, they would be registered with the VCA priority. This priority is
      reserved for the acceptor thread itself, and specifically is not included
      in the TASK_QUEUE_CLIENT categorisation. This would interfere with the
      thread reserve pools.
      
      t02011.vtc had to be adjusted to account for the new priority
      categorisation of the initial request.
      42267902
    • Nils Goroll's avatar
      remove a now pointless vtc · 8adc6731
      Nils Goroll authored
      This test is to detect a deadlock which does not exist any more. IMHO,
      the only sensible way to test for the lack of it now is to do a load
      test, which is not what we want in vtc.
      8adc6731
    • Nils Goroll's avatar
      fix missing initialization · 78c9b146
      Nils Goroll authored
      ... introduced with 3bb8b84c:
      
      in Pool_Work_Thread(), we could break out of the for (i = 0; i <
      TASK_QUEUE__END; i++) loop with tp set to the value from the previous
      iteration of the top while() loop where if should have been NULL (for no
      task found).
      
      Noticed staring at #3192 - unclear yet if related
      78c9b146
    • Nils Goroll's avatar
      generalize the worker pool reserve to avoid deadlocks · 5b190563
      Nils Goroll authored
      Previously, we used a minimum number of idle threads (the reserve) to
      ensure that we do not assign all threads with client requests and no
      threads left over for backend requests.
      
      This was actually only a special case of the more general issue
      exposed by h2: Lower priority tasks depend on higher priority tasks
      (for h2, sessions need streams, which need requests, which may need
      backend requests).
      
      To solve this problem, we divide the reserve by the number of priority
      classes and schedule lower priority tasks only if there are enough
      idle threads to run higher priority tasks eventually.
      
      This change does not guarantee any upper limit on the amount of time
      it can take for a task to be scheduled (e.g. backend requests could be
      blocking on arbitrarily long timeouts), so the thread pool watchdog is
      still warranted. But this change should guarantee that we do make
      progress eventually.
      
      With the reserves, thread_pool_min needs to be no smaller than the
      number of priority classes (TASK_QUEUE__END). Ideally, we should have
      an even higher minimum (@Dridi rightly suggested to make it 2 *
      TASK_QUEUE__END), but that would prevent the very useful test
      t02011.vtc.
      
      For now, the value of TASK_QUEUE__END (5) is hardcoded as such for the
      parameter configuration and documentation because auto-generating it
      would require include/macro dances which I consider over the top for
      now. Instead, the respective places are marked and an assert is in
      place to ensure we do not start a worker with too small a number of
      workers. I dicided against checks in the manager to avoid include
      pollution from the worker (cache.h) into the manager.
      
      Fixes #2418 for real
      
       Conflicts:
      	bin/varnishd/cache/cache_wrk.c
      	bin/varnishd/mgt/mgt_pool.c
      5b190563
  4. 20 Apr, 2021 21 commits
    • Dridi Boukelmoune's avatar
      vbe: Check failures to send the request earlier · 584a1c98
      Dridi Boukelmoune authored
      There's no point waiting for the backend to complain if we weren't able
      to properly send the backend request.
      
      Fixes #3556
      
       Conflicts:
      	bin/varnishd/cache/cache_backend.c
      584a1c98
    • Dridi Boukelmoune's avatar
      vbe: Generic sanity check of non-recyclable connections · 85204bcb
      Dridi Boukelmoune authored
      The reason we expect here can be summarized as: this was a pipe
      transaction or an error occurred. This could be much simpler if
      we replaced enum sess_close with a struct stream_close instead.
      
      Refs dc5bddbd
      85204bcb
    • Reza Naghibi's avatar
      Allow shard.reconfigure() to work on empty directors · 13a03e3a
      Reza Naghibi authored
      Also move the lock up to cover more operations.
      13a03e3a
    • Reza Naghibi's avatar
      Fix canon_point calculation · 349abc76
      Reza Naghibi authored
      349abc76
    • Reza Naghibi's avatar
      Don't change the C-L if we detect a failed stream. · f97b7346
      Reza Naghibi authored
      Previously we would read the response Content-Length from a failed oc,
      which would make the error response valid. Now, if this is detected,
      we don't touch the Content-Length.
      f97b7346
    • Martin Blix Grydeland's avatar
      Add an assert that VRT_delete_backend is only called once · f3f15136
      Martin Blix Grydeland authored
      VRT_delete_backend() sets be->cooled to non-zero as the only place where
      that is done. Assert that it is zero on entry as a check that
      VRT_delete_backend isn't called multiple times.
      f3f15136
    • Martin Blix Grydeland's avatar
      Fix handling of failed VRT_new_backend_clustered · 7523f3c1
      Martin Blix Grydeland authored
      We refuse to accept new dynamic backends while the VCL is cooling, and
      drop adding the attempted backend on the VCL's backend list when that
      condition is found. But that would cause an assert later when it is picked
      off the cool_backends list for destruction. Fix this by directly
      destroying the backend instead of going through the cooling list.
      
      Note that this patch removes the ASSERT_CLI() macro in vbe_destroy().
      7523f3c1
    • Martin Blix Grydeland's avatar
      Set be->cooled while holding backends_mtx · 48d51ff6
      Martin Blix Grydeland authored
      Several functions (VBE_Poll and vbe_destroy) tests be->cooled == 0 to
      determine which of the two lists backends and cool_backends a specific
      instance currently lives on. If the flag is in the process of being
      changed, then the wrong list head may be used and will result in strange
      bugs.
      
       Conflicts:
      	bin/varnishd/cache/cache_backend.c
      48d51ff6
    • Steven's avatar
      We need UTF8 encoding for Python3 · 0e82401e
      Steven authored
      0e82401e
    • Steven's avatar
      [CCI] Install python3 on make dist · 7191ed97
      Steven authored
      7191ed97
    • Klemens Nanni's avatar
      Prefer Python 3 tools · cd7b69af
      Klemens Nanni authored
      The last three commits already made configure recommend installing
      Python 3 packages and look for versioned executables, however with a low
      priority.
      
      This is a problem on systems such as OpenBSD 6.5 with a default Python
      version at 2.7, where 3.7 flavored Python packages get installed with
      a "-3" binary suffix.  That is, when both rst2man and rst2man-3 are
      installed at configure time, the lower version will be picked unless
      explicitly passed through `--with-feature' arguments.
      
      Regardless of this specific case, trying more specificly versioned tool
      names first seems correctly in line with recent development and less
      error prone, so change it accordingly.
      
       Conflicts:
      	configure.ac
      cd7b69af
    • Dridi Boukelmoune's avatar
      We live in the future now · b1937f71
      Dridi Boukelmoune authored
      For a given definition of "future" or "now".
      b1937f71
    • Federico G. Schwindt's avatar
      More python3 tweaking · 74ec3158
      Federico G. Schwindt authored
      74ec3158
    • Dridi Boukelmoune's avatar
      e2f4cadc
    • Dridi Boukelmoune's avatar
      Require Python >= 3.4 at build time · 1bfc346c
      Dridi Boukelmoune authored
      Until the naked "python" executable refers to python3 (currently it is
      still python2) it now takes lower precedence.
      1bfc346c
    • Simon's avatar
      Decrease sleep time when waiting for child to die. · 37b6567b
      Simon authored
      37b6567b
    • Dridi Boukelmoune's avatar
      condfetch: Handle failed stale_oc without a boc · 98391cb8
      Dridi Boukelmoune authored
      The assertion that the stale objcore of a conditional fetch cannot be
      failed unless it was streaming is incorrect. Between the moment when
      we grab the stale objcore in HSH_Lookup and the moment we try to use
      it after vcl_backend_response, the backend fetch may have completed or
      failed.
      
      Instead, we need to treat an ongoing fetch and a failed fetch as
      separate checks since the latter may happen with or without a boc.
      
       Conflicts:
      	bin/varnishd/cache/cache_fetch.c
      98391cb8
    • Nils Goroll's avatar
      Fix request body reference count assertion · f2f37448
      Nils Goroll authored
      Test case by Reza, thank you
      
      Fixes #3433
      Closes #3434
      f2f37448
    • Dridi Boukelmoune's avatar
      vbf: Prevent pooling of a Connection:close bereq · 8b36d038
      Dridi Boukelmoune authored
      Once we ask the backend to close the connection after a given request
      there is no benefit from putting the backend connection back in the
      pool. It's actually a surefire way to force a subsequent backend fetch
      to fail its first attempt and go straight to its extra chance.
      
      Since we try to maximize connection reuse this would have to come from
      VCL and a user asking for the backend to close the connection should
      have a good reason to do so, for example when the backend is known to
      misbehave under certain circumstances.
      
      Closes #3400
      Refs #3405
      8b36d038
    • Steven's avatar
      doc: Mention the effect of Connection:close in beresp · 4297c891
      Steven authored
      Original author: @dridi
      
      This commit is from ba78ebeb but
      with no analogous file in 6.0, it is added to changes-6.0.rst instead of changes-trunk.rst
      4297c891
    • Dridi Boukelmoune's avatar
      vbf: Prevent pooling of a Connection:close beresp · bb73128a
      Dridi Boukelmoune authored
      Whether the header was set by the backend or directly in VCL, it is now
      possible to signal that a backend connection should not be added back to
      the pool after a successful fetch with a Connection:close header.
      
      Pooling such a connection would be counter-productive if closing the
      session was requested by the backend itself, because it would then be
      likely that reusing the connection would result in busting the extra
      chance.
      
      Setting the Connection:close directly in VCL can help mitigating against
      a misbehaving backend.
      
      Refs #3400
      bb73128a