How to tell the namespace is ready to be polled by workers

Hi Temporal team!

I’m looking for ways to simplify Temporal development experience for new engineers from my organization. As part of that, I’ve created a small generic code that could automatically create a namespace on worker/starter application startup. The idea is to have it off for staging and production (so namespaces have to be manually created there) but be able to automatically create required namespaces on a local machine.

To do that, I make a DescribeNamespace call and it fails, make a RegisterNamespace call. This works fine in the sense that namespace is created and is visible in Temporal web, however, it’s not immediately “useful” as for ~10-15 seconds after namespace was created requests fail with

io.grpc.StatusRuntimeException: NOT_FOUND: namespace: basic_worker-namespace not found

	at io.grpc.stub.ClientCalls.toStatusRuntimeException(
	at io.grpc.stub.ClientCalls.getUnchecked(
	at io.grpc.stub.ClientCalls.blockingUnaryCall(
	at io.temporal.api.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.startWorkflowExecution(
	at io.temporal.internal.external.GenericWorkflowClientExternalImpl.lambda$start$0(
	at io.temporal.internal.common.GrpcRetryer.retryWithResult(
	at io.temporal.internal.external.GenericWorkflowClientExternalImpl.start(

I tried to run another DescribeNamespace call after RegisterNamespace but it succeeds and indicated the namespace is already created. Same with ListNamespaces.

The best workaround I’ve found for now is to make a GetWorkflowExecutionHistory request for some fake workflow id. If it fails with status code NOT_FOUND I deduce the namespace is not propagated yet, once it fails with INVALID_ARGUMENT I assume the namespace is ready and I can let worker and client request go.

Is there a way to tell that the namespace is “ready” and other calls can be initiated? I feel I’m missing something pretty obvious.

Each shard has its own namespace cache which is updated with up to 15 seconds delay. So even if you a call GetWorkflowExecutionHistory for some workflow ID succeeds it doesn’t mean that it is going to succeed for a different workflow ID as it can belong to another shard.

While it is technically possible to add a feature that would report namespace registration status watching all the namespace caches I don’t think we will have time to work on it in a near future.

So I would recommend adding 20-second sleep in your scripts after the namespace registration as a workaround.

1 Like

Thank you, Maxim!

I don’t see much value in automatic namespace registration outside of local environments and it’s totally not worth investing in a new API just for that use case.

One possible option would be reducing cache refresh time for the local environment only. If filed an issue to get this tracked.

1 Like