-
Bug
-
Resolution: Fixed
-
Low
-
9.0.0
-
1
-
Severity 3 - Minor
-
Issue Summary
When using the GitWorkTreeBuilder API with repositories stored in an external Mesh, the GitWorkTreeBuilder#execute(GitWorkTreeCallback<T>) method may fail when run in an asynchronous thread. This failure is caused by a bug in the API's logic for routing RPC calls to a Mesh node. Specifically, if the execute method is called asynchronously, any work tree commands within the callback might be routed to a Mesh node that does not have the work tree, resulting in a command failure.
Note that the issue is intermittent because, at times, the requests are correctly routed to the appropriate Mesh node, allowing the commands to succeed. Also, this issue only occurs for repositories stored in external Mesh. This does not affect repositories that are managed locally by the Mesh sidecar.
Steps to Reproduce
The issue can be replicated by calling the execute method in an asynchronous thread as follows:
// Initialize the GitWorkTreeBuilder GitWorkTreeBuilder workTreeBuilder = workTreeBuilderFactory.builder(repository) .commit("6053a1eaa1c009dd11092d09a72f3c41af1b59ad") .checkoutType(GitCheckoutType.NONE); // Use an ExecutorService to simulate asynchronous execution ExecutorService executorService = Executors.newSingleThreadExecutor(); // Call the execute method in a separate thread executorService.execute(() -> { workTreeBuilder.execute(workTree -> { // Any command executed on the workTree object // within this callback may fail if routed to // an incorrect Mesh node }); });
Expected Results
The execute method finishes successfully with no errors.
Actual Results
The execute method may fail and throw the following error in the logs.
com.atlassian.bitbucket.repository.NoSuchRepositoryException: There is no repository with ID wt/5 Suppressed: java.lang.IllegalArgumentException: The work tree was not found, it may have expired or been deleted
Workaround
Currently there is no known workaround for this behavior. A workaround will be added here when available