]> git.ipfire.org Git - thirdparty/squid.git/commit - src/Transients.cc
Identify collapsed transactions (#213)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Mon, 18 Jun 2018 16:51:34 +0000 (16:51 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Mon, 18 Jun 2018 20:22:25 +0000 (20:22 +0000)
commitd2a6dcba707c15484c255e7a569b90f7f1186383
tree1d3173b57e054cbcd4331ffc8fe49763d7991994
parentc8ab5ec6c34fbd6544cf8fac9fd6266e7651ffed
Identify collapsed transactions (#213)

Added a new CF tag to the Squid request status %Ss access log field.
This tag marks transactions that have waited for a CF initiator
transaction. This wait may happen in two cases (or their combination):

1. Classic collapsing: A client request gets collapsed on arrival
   (e.g., TCP_CF_HIT or TCP_CF_MISS).
2. Collapsed revalidation: An internal revalidation request is collapsed
   (e.g., TCP_CF_REFRESH_MODIFIED).

A CF tag approach is simple but the resulting access.log records cannot
distinguish some cases. For example, a pure collapsed revalidation
transaction (case 2) cannot be distinguished from these transactions:
* a collapsed client that got collapsed on revalidation (case 1+2);
* a collapsed client that initiated revalidation.

We may want to log more collapsing details in the future.

These changes do not affect CF initiating code.

In order to track collapsed transactions, a new CollapsingHistory class
was introduced. Since more and more non-logging code relies on ALE, this
history is kept in ALE. ClientHttpRequest uses its logType field instead
of the LogTags in ALE, so we also use logType for storing
ClientHttpRequest's CollapsedHistory. Eventually, ClientHttpRequest
should eliminate logType in favor of direct ALE use.

Also: ICP code fixing/refactoring:
* htcpSyncAle() and icpSyncAle() should not require the caller to supply
  correct LogTags because callers like fillChecklist() do not have
  access to that information (it is not stored in the transaction object
  unlike the other pieces of info that these functions copy to ALE).
* Added icpUdpData::ale to preserve master transaction info when
  messages are queued. Several icpUdpData improvements were triggered by
  this change because ale is a (second!) non-POD member and icpUdpData
  was mistreated as a POD. They include:
  - Removed icpUdpData::start as unused.
  - Removed icpUdpData::len as set but otherwise unused.
  - Removed icpUdpData::logcode as essentially duplicating msg->opcode.
* Update ICP ALE, if any, as soon as the transaction tags become known
  (instead of sometimes waiting for the ICP message to be logged). The
  ICP message may be dropped and/or never be logged, but we should keep
  ALE up to date because it is used in an increasingly many contexts.

Also found and marked an ICP memory leak. It is best to fix that in a
dedicated commit.

Also supplied URN code with ALE. Full-featured Client-based classes
already use ALE. We have not tested with URNs, but these changes may
improve logging of transactions that involve URN resolution.

Also fixed problematic StoreEntry::collapsingInitiator(). It could
return true if the entry had transients but had nothing to do with
collapsing. It also incorrectly assumed that a collapsed entry is always
marked with ENTRY_FWD_HDR_WAIT. That assumption is wrong because
Controller::allowCollapsing() does not set this flag for the entry.

We did not find a better way to track StoreEntry objects associated with
CF initiators than to add a new StoreEntry flag. Hitting an entry
flagged with ENTRY_REQUIRES_COLLAPSING requires collapsing the request.
34 files changed:
src/AccessLogEntry.h
src/CollapsingHistory.h [new file with mode: 0644]
src/FwdState.cc
src/ICP.h
src/LogTags.cc
src/LogTags.h
src/Makefile.am
src/Store.h
src/StoreClient.h
src/Transients.cc
src/Transients.h
src/acl/Asn.cc
src/adaptation/icap/History.cc
src/client_side_reply.cc
src/client_side_reply.h
src/client_side_request.cc
src/enums.h
src/htcp.cc
src/icp_v2.cc
src/icp_v3.cc
src/ipc/StoreMap.cc
src/mime.cc
src/neighbors.cc
src/peer_digest.cc
src/refresh.cc
src/store.cc
src/store/Controller.cc
src/store/Controller.h
src/store_client.cc
src/tests/stub_icp.cc
src/tests/stub_store.cc
src/tunnel.cc
src/urn.cc
src/urn.h