Comments (10)
Yes, I think right now I am doing a hard shutdown on the HikariCP Connection Pool. I did a quick look at the HikariCP issue tracker and there is a way to soft evict the connections, when shutting down the Connection Pool. This might be worth implementing or adding to the article:
For the Tenant Name. I think I really should add something like a default tenant for the Spring Boot startup. See... I don't know how you start up your application. I went great length to prevent Spring Boot magic from making connections to the database, when starting the application. It's because Spring Boot tries to automagically find out, which database and dialect you are using, and other things... thereby making connections to a database.
But this connection at Startup, which Tenant Database should it use? The first?
So this can easily be fixed, if you are setting a Tenant Name explicitly for booting the application by using the ThreadLocal implementation I have provided. I will add this to the article, because it's not obvious at all. If you set this Tenant and Spring Boot makes a database connection at startup, it will use this tenant and not err out.
from bytefish.de.
The AsyncConfig
is used for passing the tenant name into child threads when using the Spring @Async
annotation.
from bytefish.de.
Thanks again Phillip, for the prompt reply.
As far as the way I started the application, it was really very simple and lazy way of using the STS IDE.. and run as spring boot application.. as there were junits running on start up. It created this problem.
Again, might be a silly one.. is it right to say we can ditch AsyncConfig if we want?
Cheers
Vicky
from bytefish.de.
Also as you mentioned I did the exact thing of specifying a default tenant and the problem goes away.
But then what I got confused with was that is this trigger necessary for web apps which we know will land via a typical Rest Api..
from bytefish.de.
Yes, you can safely remove it, when you don't plan to use @Async
at all. Also make sure to delete the @EnableAsync
annotation on the SpringBootApplication:
from bytefish.de.
Perfect Phillip,
I will try this sometime this week and let you know how that went!
Cheers!
Vicky
from bytefish.de.
Cool, feel free to add comments here!
from bytefish.de.
Funny, I just tried to make the application crash by not setting a Tenant on Startup. I know this was problematic, when I wrote the article. But with JDK14 I cannot make it crash, even though I removed all properties, that prevent initialization. Weird.
How did you manage to make it run into an error?
from bytefish.de.
Hey Phillip,
I tried running some tests which has a complex DB operation like some joins etc. With that only few of the tests complained about the mentioned scenario.
Also please note I didn't try the same with java 14.. but on an old JDK.
Regards,
Vicky
from bytefish.de.
I have just taken a look at the HikariCP implementation of the shutdown method:
It already calls HikaiPool#softEvictConnections()
to provide a graceful shutdown. I don't think there is much more one can do when using HikariCP. The only thing I can think of is maybe calling HikariPool#softEvictConnections()
yourself and give the Queries more time to finish, by introducing a wait delay.
from bytefish.de.
Related Issues (20)
- TransactionalTestBase package? HOT 1
- Thank you for the excellent article. Unfortunately, it did not work for me. HOT 2
- Question: Usage of bytea HOT 1
- Sql minor bug HOT 1
- Auto Configuere data source in data base per tenant HOT 1
- Spring Boot Multitenancy guide - Error with AbstractRoutingDataSource HOT 3
- Query on spring abstractroutingdatasource advantage HOT 2
- Add a flow diagram HOT 7
- NEST not working HOT 1
- Adding null in AuditQueryResultUtil HOT 3
- How the tenant can be changed on runtime HOT 1
- Can't write CLR type System.DateTime to database type timestamp with time zone HOT 1
- AbstractMap used by PersonMap in SqlMapper blog entry doesn't match java.util.AbstractMap HOT 7
- Update async multi-tenant example HOT 3
- Select tenant HOT 1
- Subject: Parsing Command Line Arguments in .NET || Topic: Add basic arg validation HOT 2
- How to addnew datasource without @Scheduled HOT 1
- How can we do the reverting to a particular revision using Versioning and Auditing with spring data Envers? please provider me an example for reverting HOT 2
- Tables are not getting created while dynamically tenant details in tenant.json HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bytefish.de.