epugh opened a new pull request, #4066:
URL: https://github.com/apache/solr/pull/4066

   https://issues.apache.org/jira/browse/SOLR-18078
   
   
   # Description
   
   You can now delete any of the request handlers created by 
ImplicitHandlers.json
   
   # Solution
   
   Implemented the **Tombstone Marker** pattern to enable deletion of 
implicitly created request handlers (from `ImplicitPlugins.json`) through the 
ConfigOverlay API.
   
   I'm going to paste in a whole bunch of claude generated details for anyone 
who wants to read thorugh it....
   
   ## What Was Implemented
   
   ### 1. Core Functionality
   
   **ConfigOverlay.java** - Tombstone tracking system
   - Added `deletedPlugins` Set<String> field to track deleted plugins
   - Modified `deleteNamedPlugin()` to create tombstone markers in "deleted" 
list
   - Added `isPluginDeleted(String typ, String name)` to check deletion status
   - Added `getDeletedPlugins()` to retrieve all deleted plugin keys
   - Constructor updated to load deleted plugins from persisted JSON
   
   **RequestHandlers.java** - Handler filtering
   - Modified `initHandlersFromConfig()` to filter deleted implicit handlers
   - Checks `overlay.isPluginDeleted()` before registering each implicit handler
   
   **SolrConfigHandler.java** - Enhanced deletion logic
   - Updated `deleteNamedComponent()` to recognize and delete implicit handlers
   - Modified `pluginExists()` to exclude deleted plugins from existence checks
   
   ### 2. Data Structure
   
   The ConfigOverlay JSON now supports a "deleted" array:
   
   ```json
   {
     "overlay": {
       "requestHandler": {
         "/custom": {...}
       },
       "deleted": [
         "requestHandler:/admin/ping",
         "requestHandler:/sql"
       ]
     }
   }
   ```
   
   ### 3. Test Coverage
   
   **Unit Tests (TestConfigOverlay.java)** - 6 tests, all passing ✅
   - `testPaths()` - Existing test, still passing
   - `testSetProperty()` - Existing test, still passing
   - `testDeletedPluginTombstone()` - Tests basic tombstone creation
   - `testDeletedPluginFromOverlay()` - Tests deleting overlay-defined plugins
   - `testDeletedPluginPersistence()` - Tests loading from JSON
   - `testDeleteSamePluginTwice()` - Tests idempotent deletion
   
   **Integration Tests (TestSolrConfigHandler.java)** - 9 tests, all passing ✅
   - All existing tests continue to pass
   - `testDeleteImplicitHandler()` - New test for implicit handler deletion
   
   ## How It Works
   
   1. User issues delete command: `POST /config {"delete-requesthandler": 
"/admin/ping"}`
   2. SolrConfigHandler processes the command
   3. ConfigOverlay adds "requestHandler:/admin/ping" to the "deleted" list
   4. Overlay is persisted to `configoverlay.json`
   5. Core is reloaded
   6. RequestHandlers.initHandlersFromConfig() filters out deleted implicit 
handlers
   7. Handler is no longer available
   
   ## Usage Examples
   
   ### Delete an Implicit Handler
   
   ```bash
   curl -X POST http://localhost:8983/solr/collection1/config \
     -H 'Content-Type: application/json' \
     -d '{
       "delete-requesthandler": "/admin/ping"
     }'
   ```
   
   ### View Deleted Handlers
   
   ```bash
   curl http://localhost:8983/solr/collection1/config/overlay
   ```
   
   Response:
   ```json
   {
     "responseHeader": {
       "status": 0,
       "QTime": 1
     },
     "overlay": {
       "deleted": [
         "requestHandler:/admin/ping"
       ]
     }
   }
   ```
   
   ### Recreate a Deleted Handler
   
   After deletion, you can create a new handler with the same name:
   
   ```bash
   curl -X POST http://localhost:8983/solr/collection1/config \
     -H 'Content-Type: application/json' \
     -d '{
       "create-requesthandler": {
         "name": "/admin/ping",
         "class": "org.apache.solr.handler.DumpRequestHandler"
       }
     }'
   ```
   
   ## Files Modified
   
   - `solr/core/src/java/org/apache/solr/core/ConfigOverlay.java`
   - `solr/core/src/java/org/apache/solr/core/RequestHandlers.java`
   - `solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java`
   - `solr/core/src/test/org/apache/solr/core/TestConfigOverlay.java`
   - `solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java`
   
   ## Key Design Decisions
   
   ### Why Tombstone Marker?
   
   We evaluated three approaches:
   1. **Tombstone Marker** (chosen) ✅
   2. Null value marker
   3. Dedicated deletion API
   
   **Tombstone was selected because:**
   - ✅ Clean separation of concerns
   - ✅ Doesn't pollute plugin data structure
   - ✅ Easy to check if plugin is deleted
   - ✅ Works for both implicit and overlay plugins
   - ✅ Extensible to other plugin types
   - ✅ Serializes/persists naturally in JSON
   
   # Tests
   
   Add tests + manually tested
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to