Closed qdzo closed 1 year ago
can you provide the example test case which fails occasionally ?
I think the issue may be related to schema definition
@carbon-hvze Same problem in another place. Please check schema below
create-box
{:zen/tags #{zenbox/rpc}
:zen/desc "Create box"
:params {:type zen/map
:require #{:id :fhirVersion}
:keys {:id {:type zen/string :regex "^[a-z][a-z0-9]{4,}$"}
:fhirVersion {:type zen/string :regex "^fhir-([1,3,4])\\.([0-4,8])\\.([0-2])$"}
:description {:type zen/string}
:env {:type zen/any}}}}
Here's code reproducing the problem
(dotimes [_ 100]
(def ztx (zen.core/new-context))
(def lock (promise))
(zen.core/load-ns ztx '{:ns myns
sym {:zen/tags #{zen/schema}
:type zen/map
:keys {:a {:type zen/string}}}})
(def futures
(mapv (fn [n]
(future
@lock
(zen.core/validate ztx
#{'myns/sym}
{:a "1"})))
[1 2]))
(deliver lock :unlock)
(mapv (fn [req-fut] @req-fut) futures))
Problem is gone for us
It looks like there are some concurrency issue with schema compilaiton.
In one of the test we encounter such issue when calling
zen.v2_validation/validate
.When running test 2nd time - everything is ok. But after recreating zen-context - fail repeats.
For now I failed in making simple reproducible test case.