await_cluster_ready.sql 1.2 KB

123456789101112131415161718192021222324252627
  1. -- Copyright Materialize, Inc. and contributors. All rights reserved.
  2. --
  3. -- Licensed under the Apache License, Version 2.0 (the "License");
  4. -- you may not use this file except in compliance with the License.
  5. -- You may obtain a copy of the License in the LICENSE file at the
  6. -- root of this repository, or online at
  7. --
  8. -- http://www.apache.org/licenses/LICENSE-2.0
  9. --
  10. -- Unless required by applicable law or agreed to in writing, software
  11. -- distributed under the License is distributed on an "AS IS" BASIS,
  12. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. -- See the License for the specific language governing permissions and
  14. -- limitations under the License.
  15. {% macro await_cluster_ready(cluster, poll_interval=15, lag_threshold='1s') %}
  16. {% for i in range(1, 100000) %}
  17. {% if is_cluster_ready(cluster, lag_threshold) %}
  18. {{ return(true) }}
  19. {% endif %}
  20. -- Hydration takes time. Be a good
  21. -- citizen and don't overwhelm mz_catalog_server
  22. {{ adapter.sleep(poll_interval) }}
  23. {% endfor %}
  24. {{ exceptions.raise_compiler_error("Cluster " ~ deploy_cluster ~ " failed to hydrate within a reasonable amount of time") }}
  25. {% endmacro %}