clebertsuconic commented on code in PR #5498: URL: https://github.com/apache/activemq-artemis/pull/5498#discussion_r1959811848
########## artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java: ########## @@ -1262,8 +1324,16 @@ private boolean writePage(Message message, Transaction tx, RouteContextList listCtx, Function<Message, Message> pageDecorator) throws Exception { - lock.writeLock().lock(); - + if (timedWriter == null) { + // in case timedWriter is not being used, we need to guarantee a writeLock. + // because there's no way to upgrade from reading to writeLock + writeLock(); + } else { + // if we are using a timedWritter, we can just use a readLock to guarantee paging is not changed + // this will issue the writer on a different thread, and we can just use a readLock + readLock(); Review Comment: I will improve the comment there. We need to keep a lock while we checked for isPaging... we need to make sure the system is paging for the entire duration of the method, hence the readLock. When timedWriter is null (which will only happen in tests), I still need to hold the lock, however later on when moving to a different page a writeLock will be needed, and that would break things with a deadlock. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For additional commands, e-mail: gitbox-h...@activemq.apache.org For further information, visit: https://activemq.apache.org/contact