Repository navigation
fix(mongodb): log an index creation failure on one line, the stack trace at debug - #16981
Open
borinquenkid wants to merge 1 commit into
Open
borinquenkid wants to merge 1 commit into
borinquenkid wants to merge 1 commit into
Conversation
…ace at debug MongoDatastore.initializeIndices logged a MongoCommandException from createIndex at ERROR together with the exception, so a server error such as 86 IndexKeySpecsConflict printed a huge stack trace at every startup for a condition the operator must fix in the mapping or the database. The ERROR event now carries only the entity, the index definition and the server message; the stack trace goes to a separate DEBUG event. This covers the single, compound and property index paths. The module's tests ran on slf4j-nop, which cannot capture log events, so logback-classic (managed by the BOM) replaces it as the single SLF4J binding for the tests, and a new spec provokes a real index conflict against a MongoDB container and asserts on the captured events. Fixes #15667 Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
✅ All tests passed ✅🏷️ Commit: ac591ef Learn more about TestLens at testlens.app/docs. |
jamesfredley
approved these changes
Nov 14, 2026
jamesfredley
left a comment
Contributor
There was a problem hiding this comment.
An index creation failure is still logged with the entity, the index, and the reason. The stack trace is at debug, and a success is not logged as a failure.
This branch has not been deployed
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.
Fixes #15667 (a merge to 7.0.x does not close it, so it is closed by hand once the merge-ups land).
MongoDatastore.initializeIndiceslogged aMongoCommandExceptionfromcreateIndexat ERROR together with the exception. A server error such as 86IndexKeySpecsConflictthen printed a very long stack trace at every startup, for a condition the operator has to fix in the mapping or in the database.Change: the ERROR event carries only the entity, the index definition (or property) and the server message, as before. The stack trace goes to a separate DEBUG event. This covers the three paths: a single index, a compound index and a property index.
Only the 7.x line. On 8.0.x and 8.1.x the reported case goes through
reconcileIndexConflict(#15747, #16208), which logs a one-line "Index conflict ..." message and does not attach the exception, so nothing changes there. 7.1.x and 7.2.x do not have that code; the merge-ups carry this fix.Tests:
MongoDatastoreIndexFailureLogSpeccreatesname_1with the driver in a MongoDB Testcontainer, then starts aMongoDatastorewhose entity mapsnameas a unique index, which makes the server answer 86. It asserts one ERROR event with the entity name and the server message and no throwable, and a DEBUG event that carries theMongoCommandException. It failed before the change (the ERROR event carried the exception) and passes after. All 569 tests ofgrails-data-mongodb-corepass (0 failures, 19 skipped); CodeNarc and Checkstyle are clean.Test dependency: the module's tests ran on
slf4j-nop, which cannot capture log events.logback-classic(version managed by the BOM) replaces it as the single SLF4J binding of the tests, so the spec can attach aListAppender;testRuntimeClasspathshows no second binding.Two of the three reviewers (matrei, codeconsole, jdaugherty), as 7.0.x is released. The
run cilabel is set because 7.0.x skips the tests otherwise and the new spec needs the container.https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL