yukon created ROCKETMQ-261:
------------------------------

             Summary: 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.1.0-incubating, 4.0.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)

Reply via email to