ISSUE DESCRIPTION Removing a registered or subscribed service leaves stale local…
- User
ISSUE DESCRIPTION
Removing a registered or subscribed service leaves stale local metadata
After a successful unregister or unsubscribe operation, the corresponding provider or consumer URL must no longer participate in local metadata, service matching, or revision calculation. Removing one URL must preserve unrelated registrations. If the remote operation fails, local metadata must not be removed as though the operation succeeded.
Interface
Type: Function Name: RemoveService Path: metadata/metadata.go Input: registryId string, url *common.URL Output: (no return value) Description: Removes a provider service URL from the local metadata for the given registry. Use this during unregister flows to keep the in-memory application-level metadata consistent with the actual exported services.
Type: Function Name: RemoveSubscribeURL Path: metadata/metadata.go Input: registryId string, url *common.URL Output: (no return value) Description: Removes a subscribed service URL from the local metadata for the given registry. Use this during unsubscribe flows to ensure stale subscribed URLs are cleaned from the application-level metadata.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /dubbo-go, current file: none) bash-$
- Assistant
I’ll trace the metadata add paths and unregister/unsubscribe call sites, reproduce the stale-state behavior with the existing tests or a temporary harness, then implement symmetric removal only after successful remote operations and run the relevant test suites.
- Assistant
The metadata package currently exposes only add operations. I found that service-discovery registry registration/subscription is where those adds occur, so I’ll inspect its success/error ordering and the underlying
MetadataInfokey structures to design removals that preserve unrelated URLs and revision semantics. - Assistant
MetadataInfoalready has removal methods, but provider removal is unsafe when multiple exported URLs share a match key: it unconditionally deletes the sharedServicesentry even if another registration remains. I’ll inspect the complete registry methods and revision implementation, then update both the public metadata API and flow integration with correct success-only ordering. - Assistant
The flow methods return errors, making success-only cleanup straightforward: call
RemoveServiceafterUnRegisterServicesucceeds andRemoveSubscribeURLafter mapping removal succeeds. Before editing, I’ll verify URL equality conventions and tests/mocks around these methods, because removals should follow the registry contract’s full-URL matching rather than relying accidentally on pointer identity. - Assistant
URL.URLEqualintentionally ignores host/port, so it is not suitable for the full-URL removal contract. The stored URL object is normally the same pointer, but the public removal API should also work with an equivalent URL value. I’ll use canonicalURL.String()equality (with pointer fast path), and make provider service matching derive from all remaining exported URLs so one removal cannot erase another registration’s service metadata. - Assistant
I’ll now implement three coordinated changes: value-based removal in
MetadataInfo, shared-match-key preservation for providers, and package-levelRemoveService/RemoveSubscribeURLwrappers. Then I’ll wire them into application-level unregister/unsubscribe only after the remote operation reports success, including successful no-op unsubscribe cleanup. - Assistant
The implementation is in place. I’ll run the focused metadata and service-discovery registry tests first. I’ll also inspect the revision customizer during the run to ensure it derives revisions dynamically from the cleaned URL collections rather than trusting the cached
MetadataInfo.Revision. - Assistant
The focused tests could not start because this shell has neither
GOMODCACHEnorGOPATHconfigured; this is an environment issue, not a compile failure. I’ll configure a temporary writable module/cache path outside the repository and rerun. After that, I’ll use a temporary standalone test (removed before submission) to explicitly verify equal-value removal, unrelated registration preservation, and failed remote-operation retention. - Assistant
Focused tests pass, and revision calculation reads the URL collections dynamically, so cleanup affects subsequent revisions as required. I’ll add short-lived local test files (not retained) to reproduce the original stale metadata and verify edge cases, including remote failures. First I need the existing service-discovery mocks’ failure controls so the temporary flow tests reuse repository conventions.
- Assistant
The existing mock supports unregister failure directly but not mapping-removal failure. I’ll temporarily add package-local tests for the metadata removal semantics and unregister success/failure ordering, run them, then delete the test files. This directly reproduces the reported stale provider behavior without modifying retained tests.
- Assistant
The temporary reproduction passed: failed unregister retained metadata; retry success removed it; equivalent URL values were removable; and same-match-key plus unrelated registrations were preserved. I’ll now run the broader registry test suite, inspect the final diff for accidental changes, and check that no temporary files remain.
- Assistant
All metadata-focused and registry-wide tests pass, formatting checks are clean, and no temporary tests remain. One final review will confirm the success-only ordering and the exact three-file scope; if clean, I’ll submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →