KeyValueMapOperations reads different values

Hi,

We use Apigee Edge Eval version and faced an issue. KVM returns different values for the same request using KeyValueMapOperations policy. We have one instance, due to eval env limitations. The ExpiryTimeInSecs is set to  2147483647 by the business requirements. The debug session shows different values for each hit. One hit could show an empty array and each 2nd or 3rd  request returns an actual stored value. The behavior is reproduced at the several eval environments installed for the projects from scratch. BTW an environment and account created mutch earlier(several years ago) and probably in US region works as expected. We use an instance in eu-west1 region.empty_val.pngreal_val.png  

0 4 121
4 REPLIES 4

can you share your KVM policy and KVM information? That may help to debug.

Hi @perandr , do you want to elaborate on what each policy that you have used does? That will help understand the flow. Of course once you remove anything confidential, you could upload the proxy / policy code so that we could take a look.
 
Just thinking about it without more information, are these back to back calls? I suppose the call #1 would have Put the value in the KVM? It is quite possible that the second call was so close that the value was not yet replicated. By the time the third call was fired, the data was saved and was retrievable. 


Also what do the other flow variables say? Are you getting a hit on the key but the value is empty, or is the key itself not present - in the latter case, it is not yet replicated across the message processor instances.


At any time did you receive a null after you have started getting back the value from the Get operation? 

The flow consists of several steps. 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
    <PreFlow name="PreFlow">
        <Request>
            <Step>
                <Name>verify-api-key</Name> <!-- VerifyAPIKey policy as the security measure -->
            </Step>
            <Step>
                <Name>Key-Value-Map-Get</Name> <!-- KeyValueMapOperations policy - reads KVM to context. -->
            </Step>
            <Step>
                <Name>Set-KVM</Name> <!-- Javascript policy. Merge context variables and request data and sets the variables -->
            </Step>
            <Step>
                <Name>Key-Value-Map-Set</Name> <!-- KeyValueMapOperations policy - saves the variables to KVM. Variables same as in Key-Value-Map-Get. -->
            </Step>
        </Request>
        <Response/>
    </PreFlow>
    <Flows/>
    <PostFlow name="PostFlow">
        <Request/>
        <Response>
            <Step>
                <Name>post-process</Name> <!-- Javascript policy. Used for output purpose -->
            </Step>
        </Response>
    </PostFlow>
    <HTTPProxyConnection>
        <BasePath>/kvm-settings</BasePath>
        <VirtualHost>secure</VirtualHost>
    </HTTPProxyConnection>
    <RouteRule name="noroute"/>
</ProxyEndpoint>

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="Key-Value-Map-Get" mapIdentifier="Key-Value-Map">
<DisplayName>Key Value Map Extract Filters</DisplayName>
<Scope>environment</Scope>
<ExpiryTimeInSecs>2147483647</ExpiryTimeInSecs>
<Properties/>
<Get assignTo="header_0">
<Key>
<Parameter>header_0</Parameter>
</Key>
</Get>
<Get assignTo="header_1">
<Key>
<Parameter>header_1</Parameter>
</Key>
</Get>

<!-- HERE SHOULD BE 60 HEADER VARIABLES -->

</KeyValueMapOperations>

One more update I observed.  When the service is called several times with the same request body, the value changes.