Jepsen worker thread is overriding variable value, is this exprected?

15 views
Skip to first unread message

sapan jain

unread,
Aug 26, 2020, 4:57:07 AM8/26/20
to Jepsen Talk
Hello Experts, 

I am trying Jepsen with concurrency. 
During INVOKE two workers has different payload(key=value), just before calling actual (http/put <args>) it had override the payload, due to which subsequent GET/READ has wrong payload and it fails during consistency check. 


Could anyone please suggest how to resolve this, such that Worker Threads will be intact to their local values? Has anyone also faced the same issue? 


Code Snippet
-------------
(defn put-test "this is to test http PUT command "
  [uri key val]
  (def uri1 (str (:endpoint uri)  "/" base-path "/" api-version "/" ki))
  (def put_body_content (str "{ \"acl\":[{\"provider\": \"TLS\", \"domain\": \"\",
                                    \"grants\": [ \"all\"] }],
                                    \"payload\" :{\"data_key\": \"" val "\"}}"))
  (def put_opts {:basic-auth ["notused_user" "notused_psswd"]
             :keystore keywallet
             :keystore-pass "notused_psswd"
             :trust-store keywallet
             :trust-store-pass "notused_psswd"
             :accept :json
             :body put_body_content
             }
    )


   (try+
    (println (.getName (Thread/currentThread)) "PUT-->" uri1 " val--> " val)
    (println (.getName (Thread/currentThread)) "BODY-->" put_opts)
    (parse (http/put uri1 put_opts) )
)



Print Output for debug purpose 
----------------------------------------------------

INFO [2020-08-25 23:24:50,364] jepsen worker 6 - jepsen.util 6  :invoke :put    18
INFO [2020-08-25 23:24:50,364] jepsen worker 0 - jepsen.util 0  :invoke :put    32
jepsen worker 6 PUT--> https://<hostname:port>/root_0  val-->  18
jepsen worker 0 PUT--> https://<hostname:port>/root_0  val-->  32

jepsen worker 6 BODY--> 
:body {acl":[{"provider": "TLS", "domain": "","payload" :{"data_key": "32"}}}
jepsen worker 0 BODY--> 
:body { "acl":[{"provider": "TLS", "domain": "","payload" :{"data_key": "32"}}}

History.EDN
------------------------------
{:type :invoke, :f :put, :value 18, :process 6, :time 931479717595, :index 84734}
{:type :invoke, :f :put, :value 32, :process 0, :time 931479767668, :index 84735}



Thanks in advance, 
Sapan 

Kyle Kingsbury

unread,
Aug 26, 2020, 9:52:23 AM8/26/20
to ta...@jepsen.io
On 8/26/20 4:57 AM, sapan jain wrote:
Hello Experts, 

I am trying Jepsen with concurrency. 
During INVOKE two workers has different payload(key=value), just before calling actual (http/put <args>) it had override the payload, due to which subsequent GET/READ has wrong payload and it fails during consistency check. 

Could anyone please suggest how to resolve this, such that Worker Threads will be intact to their local values? Has anyone also faced the same issue?

Code Snippet
-------------
(defn put-test "this is to test http PUT command "
  [uri key val]
  (def uri1 (str (:endpoint uri)  "/" base-path "/" api-version "/" ki))
  (def put_body_content (str "{ \"acl\":[{\"provider\": \"TLS\", \"domain\": \"\"

Hello Sapan,

This is more of a Clojure question than something specific to Jepsen. `def` assigns global, mutable variables; it's typically used for defining functions and constants. For lexical variables, which I suspect is what you want here, try `let`. You can find plenty of examples in the tutorial documentation:

https://github.com/jepsen-io/jepsen/blob/master/doc/tutorial/index.md

--Kyle

sapan jain

unread,
Aug 27, 2020, 4:12:04 AM8/27/20
to ta...@jepsen.io
Hi Kyle, 

Wow! It worked. Thanks a lot for your help.

Your work inspires me to explore more. 

Thanks,
Sapan

--
You received this message because you are subscribed to a topic in the Google Groups "Jepsen Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/a/jepsen.io/d/topic/talk/xyjrQFxagC4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to talk+uns...@jepsen.io.
To view this discussion on the web visit https://groups.google.com/a/jepsen.io/d/msgid/talk/dd618621-9d73-20a4-7e50-1cc8a4a3d0e3%40jepsen.io.
Reply all
Reply to author
Forward
0 new messages