Repository navigation
[#162] Stop the XML search at the handler's first false and call the handler outside the file lock - #204
Open
maximthomas wants to merge 4 commits into
Conversation
…ock and stop at the first false
… hold up a change on another
… file lock before asserting it waits searchesOnOneFileStillTakeTurnsBuildingResults asserted the wait with a 500 ms negative await, which stayed green on a no-lock executeQuery when the second thread started late. It now waits until that thread is BLOCKED on the file's shared handler, or has reached the stub, and then asserts. Also move the init() comment back above the call it explains.
maximthomas
marked this pull request as ready for review
October 23, 2026 18:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #162.
XMLConnector.executeQuerypassed every result to the handler insidesynchronized (getLock())and ignored thefalseit returned.producerBufferSize= 0, a handler that returnsfalseon the first object was called for every object in the file. The loop now stops at the firstfalse.create,update,deleteand search on the file. A handler that changes the same file never returned at all: with the default buffer of 100, the connector's thread holds the lock while it waits for room in the buffer, and the caller's thread, inside the handler, waits for the lock. A search over 150 accounts whose handler callsfacade.updateon the first one hangs at 247458d and completes in about a second with this change. The search now builds its result list under the lock and calls the handler after leaving it. The list holds finishedConnectorObjects with copied values and no DOM references.lockMapwas a staticHashMapread and written under each connector instance's own monitor. It was keyed bygetAbsolutePath(), sodir/./f.xmlanddir/f.xmlgot different locks while they shared one cached handler, which is keyed bygetCanonicalPath().lockMapandgetLock()are gone. Each connector now locks on the file's sharedConcurrentXMLHandlerfromXMLHandlerCache: there is one per canonical path, created underXMLConnector.class, so every connector on the file locks the same object.create,updateanddeletestay under the lock. The log lineQuery returned {0} object(s)now counts the objects passed to the handler.Tests
New in
XMLConnectorTests:searchStopsAtTheFirstFalse: a facade withsetProducerBufferSize(0)searches five accounts with a handler that returnsfalse. The handler is called once; it was called 5 times before.searchHandlerDoesNotHoldUpAChangeOnTheSameFile: while one connector's search handler blocks, a second connector on the same file creates an account within 10 s. Before, thecreatetimed out.searchesOnOneFileStillTakeTurnsBuildingResults: two connectors on one file, one of them through a./path. The second search waits while the first builds its results. It fails with the old absolute-path key, with a lock per connector instance, and with no lock inexecuteQuery.searchOnOneFileDoesNotHoldUpAChangeOnAnotherFile: a blocked search on one file does not hold up acreateon another. It fails if all files share one lock.The last two tests put a stub handler in
XMLHandlerCache. The unsupported methods of the existingBlockingHandlerstub moved to a sharedStubHandler.Not changed
authenticatetakes the handler's read lock but not the per-file lock, as before.