mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
smaller transactions under heavy load
This commit is contained in:
@@ -71,7 +71,7 @@ public class FeedQueues {
|
|||||||
FeedRefreshContext context = takeQueue.poll();
|
FeedRefreshContext context = takeQueue.poll();
|
||||||
|
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
UnitOfWork.run(sessionFactory, () -> refill());
|
refill();
|
||||||
context = takeQueue.poll();
|
context = takeQueue.poll();
|
||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
@@ -108,7 +108,7 @@ public class FeedQueues {
|
|||||||
// add feeds that are up to refresh from the database
|
// add feeds that are up to refresh from the database
|
||||||
int count = batchSize - contexts.size();
|
int count = batchSize - contexts.size();
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
List<Feed> feeds = feedDAO.findNextUpdatable(count, getLastLoginThreshold());
|
List<Feed> feeds = UnitOfWork.run(sessionFactory, () -> feedDAO.findNextUpdatable(count, getLastLoginThreshold()));
|
||||||
for (Feed feed : feeds) {
|
for (Feed feed : feeds) {
|
||||||
contexts.add(new FeedRefreshContext(feed, false));
|
contexts.add(new FeedRefreshContext(feed, false));
|
||||||
}
|
}
|
||||||
@@ -134,8 +134,9 @@ public class FeedQueues {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update all feeds in the database
|
// update all feeds in the database
|
||||||
List<Feed> feeds = map.values().stream().map(c -> c.getFeed()).collect(Collectors.toList());
|
List<Feed> feeds = map.values().stream().filter(c -> config.getApplicationSettings().getHeavyLoad() ? !c.isUrgent() : true)
|
||||||
feedDAO.merge(feeds);
|
.map(c -> c.getFeed()).collect(Collectors.toList());
|
||||||
|
UnitOfWork.run(sessionFactory, () -> feedDAO.merge(feeds));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user