More than 1 Couchbase Environments found

@unhuman the tracking is kept simple (a static counter incremented and checked during construction of the env) and I think there might be rare but legit corner cases where 2 environments actually make sense so we want to issue a warning to the user, not forcibly change the behavior.

It’s more about limiting creation of multiple environments than about duplicates as in “exactly the same configuration” (a scenario where auto-deduplication could have been implemented, but with the added complexity of managing these checks outside of the constructor of the env, while ensuring they are performed everywhere the env can be created by the user, etc…).

hi @daschl ,

I also get the same error.
In my case, I’m using flink with 3 different jobs.
Each flink job has it’s own connection (I’m not sure how to share that env from different jar / job)
Is it safe to ignore that warning?
Let me know how to fix it.
Thanks

If you cannot share it is OK to ignore it in smaller numbers, but be informed that it is not the best use of resources (thread pools etc). If you can, share it. If it runs in the JVM on the same classloader, using a singleton with static might work?

Hi @daschl ,

Yes, it’s possible using same core using singleton, but this means i will remove the disconnect part?
Bcs if I close / disconnect 1 of my job, the other might be impacted.

@Han_Chris1 you can call disconnect on each Cluster where you share the environment no problem, the only thing you need to be careful is how you shut down the environment itself at the end. Ideally there is some kind of shutdown hook that flink provides you, or lets you know it’s going to complete. In the worst case you can leave out the environment shutdown since it has dameon threads and will not block anything. But it’s important to disconnect your clusters on shutdown, since that will make sure that there are no outstanding operations.