File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77use Doctrine \DBAL \Driver \Statement ;
88use Doctrine \DBAL \ParameterType ;
99use Keboola \TableBackendUtils \Connection \Exception \DriverException ;
10+ use Retry \BackOff \ExponentialBackOffPolicy ;
11+ use Retry \BackOff \ExponentialRandomBackOffPolicy ;
12+ use Retry \BackOff \UniformRandomBackOffPolicy ;
13+ use Retry \Policy \CallableRetryPolicy ;
14+ use Retry \Policy \SimpleRetryPolicy ;
15+ use Retry \RetryProxy ;
1016use Throwable ;
1117
1218class SnowflakeStatement implements Statement
@@ -81,9 +87,33 @@ public function execute($params = null): Result
8187 }
8288 }
8389
90+ $ proxy = new RetryProxy (
91+ new CallableRetryPolicy (
92+ function (Throwable $ e ): bool {
93+ if (str_contains ($ e ->getMessage (), 'SYSTEM$ALLOWLIST ' )) {
94+ // Retry in case of SYSTEM$ALLOWLIST error #prod_24_7___inc_25140
95+ // this is usually accompanied with SNFLK incidents
96+ // or can happen in case hostname is wrong
97+ return true ;
98+ }
99+ return false ;
100+ },
101+ 5 , // 5 attempts
102+ ),
103+ new UniformRandomBackOffPolicy (
104+ 3_000 , // 3 seconds
105+ 10_000 , // 10 seconds
106+ ),
107+ );
108+
84109 try {
85- odbc_execute ($ this ->stmt , $ this ->repairBinding ($ this ->params ));
86- } catch (Throwable $ e ) {
110+ $ proxy ->call (function () {
111+ odbc_execute (
112+ $ this ->stmt ,
113+ $ this ->repairBinding ($ this ->params ),
114+ );
115+ });
116+ } catch (Throwable ) {
87117 throw DriverException::newFromHandle ($ this ->dbh );
88118 }
89119
You can’t perform that action at this time.
0 commit comments