Product check at startup

edit

Since v7.14.0, the client performs a required product check before the first call. This pre-flight product check allows the client to establish the version of Elasticsearch that it is communicating with.

The product check generally requires a single additional HTTP request to be sent to the server as part of the request pipeline before the first API call is sent. In most cases, this will succeed during the first API call that the client sends. Once the product check succeeds, no further product check HTTP requests are sent for subsequent API calls.

var audit = new Auditor(() => VirtualClusterWith
    .Nodes(1)
    .ProductCheck(r => r.SucceedAlways())
    .ClientCalls(r => r.SucceedAlways())
    .StaticConnectionPool()
    .Settings(s => s.DisablePing())
);

audit = await audit.TraceCalls(skipProductCheck: false,
    new ClientCall() {
        { ProductCheckOnStartup },
        { ProductCheckSuccess, 9200 }, 
        { HealthyResponse, 9200 } 
    },
    new ClientCall() {
        { HealthyResponse, 9200 } 
    }
);

as this is the first call, the product check is executed

following the product check, the actual request is sent

subsequent calls no longer perform product check

Here’s an example with a single node cluster which fails for some reason during the first product check attempt.

var audit = new Auditor(() => VirtualClusterWith
    .Nodes(1, productCheckSucceeds: false)
    .ProductCheck(r => r.Fails(TimesHelper.Once, 429))
    .ProductCheck(r => r.SucceedAlways())
    .ClientCalls(r => r.SucceedAlways())
    .StaticConnectionPool()
    .Settings(s => s.DisablePing())
);

audit = await audit.TraceCalls(skipProductCheck: false,
    new ClientCall() {
        { ProductCheckOnStartup },
        { ProductCheckFailure, 9200 } 
    },
    new ClientCall() {
        { ProductCheckOnStartup },
        { ProductCheckSuccess, 9200 }, 
        { HealthyResponse, 9200 } 
    },
    new ClientCall() {
        { HealthyResponse, 9200 } 
    }
);

as this is the first call, the product check is executed, but times out

as the previous product check failed, it runs again on the second call and this time it succeeds

this time the main API call is sent and also succeeds

subsequent calls no longer perform product check

Here’s an example with a three node cluster which fails (due to too many requests) during the first and second product check attempts.

var audit = new Auditor(() => VirtualClusterWith
    .Nodes(3, productCheckSucceeds: false)
    .ProductCheck(r => r.FailAlways(429))
    .ProductCheck(r => r.OnPort(9202).SucceedAlways())
    .ClientCalls(r => r.SucceedAlways())
    .StaticConnectionPool()
    .Settings(s => s.DisablePing())
);

audit = await audit.TraceCalls(skipProductCheck: false,
    new ClientCall() {
        { ProductCheckOnStartup },
        { ProductCheckFailure, 9200 }, 
        { ProductCheckFailure, 9201 }, 
        { ProductCheckSuccess, 9202 }, 
        { HealthyResponse, 9200 } 
    },
    new ClientCall() {
        { HealthyResponse, 9201 } 
    }
);

this is the first call, the product check is executed, but fails on this node

the next node is also tried and fails

the third node is tried, successfully responds and the product check succeeds

the actual request is sent and succeeds

subsequent calls no longer perform product check