Skip to content

Sometimes getMapper exception #2890

@uniquewings

Description

@uniquewings

MyBatis version

3.5.9

Test case or example project

We have an application, it will start a grpc server, will load all mapper at main thread, and will receive business task from grpc client in grpc thread pool. We sometimes get the exception "Type xxx is not known to the MapperRegistry", but when we check the appliction log, we are confused why the exception will occur.

  1. first, we use sqlSessionTemplate.getConfiguration().addMapper(mapper); to add all the mappers. (main thread)
  2. then we use sqlSessionTemplate.getConfiguration().hasMapper(mapper); to check if the mapper add success.(main thread)
  3. last we will will wait mapper load finished by step1 and step 2, and then use sessionTemplate.getMapper(mapper); to get the mapper to use.(grpc thread pool)

As we check the code of MapperRegistry, when addMapper end, there's no way to remove mapper from the knownMappers. How did the exception occur when getMapper at step 3.

We expect getMapper success everytime at step 3.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions