[
https://issues.apache.org/jira/browse/ROCKETMQ-261?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16123404#comment-16123404
]
ASF subversion and git services commented on ROCKETMQ-261:
----------------------------------------------------------
Commit 332df78e2bb6caadfc6f4714450000ebb1f9d224 in incubator-rocketmq's branch
refs/heads/develop from [~Yukon]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=332df78 ]
[ROCKETMQ-261] Use write lock when destroy IndexService
> IndexService may block ReputMessageService
> ------------------------------------------
>
> Key: ROCKETMQ-261
> URL: https://issues.apache.org/jira/browse/ROCKETMQ-261
> Project: Apache RocketMQ
> Issue Type: Bug
> Components: rocketmq-store
> Affects Versions: 4.0.0-incubating, 4.1.0-incubating
> Reporter: yukon
> Assignee: yukon
> Fix For: 4.2.0-incubating
>
>
> So far, ReputMessageService will do two things serially:
> 1. Dispatch message to consume queue.
> 2. Build message index
> IndexService uses read/write lock to ensure thread safe, build index will
> acquire read lock, while clean index files will hold write lock for a long
> time. That means clean index files will block build index, hence will block
> dispatch consume queue and influence real-time of consumption.
> {code}
> private void deleteExpiredFile(List<IndexFile> files) {
> if (!files.isEmpty()) {
> try {
> this.readWriteLock.writeLock().lock();
> for (IndexFile file : files) {
> boolean destroyed = file.destroy(3000);
> destroyed = destroyed && this.indexFileList.remove(file);
> if (!destroyed) {
> log.error("deleteExpiredFile remove failed.");
> break;
> }
> }
> } catch (Exception e) {
> log.error("deleteExpiredFile has exception.", e);
> } finally {
> this.readWriteLock.writeLock().unlock();
> }
> }
> }
> {code}
> Action:
> Submits task 1 and 2 to different thread, to avoid mutual influence.
> Or uses lock-free algorithm in IndexService.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)