denis-chudov commented on code in PR #3219: URL: https://github.com/apache/ignite-3/pull/3219#discussion_r1509428532
########## modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/CursorCleanupRequestHandler.java: ########## @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.tx.impl; + +import org.apache.ignite.internal.network.MessagingService; +import org.apache.ignite.internal.tx.message.CloseCursorsBatchMessage; +import org.apache.ignite.internal.tx.message.TxMessageGroup; + +/** + * Handles Cursor Cleanup request ({@link CloseCursorsBatchMessage}). + */ +public class CursorCleanupRequestHandler { + + /** Messaging service. */ + private final MessagingService messagingService; + + /** Resources registry. */ + private final RemotelyTriggeredResourceRegistry resourcesRegistry; + + /** + * The constructor. + * + * @param messagingService Messaging service. + * @param resourcesRegistry Resources registry. + */ + public CursorCleanupRequestHandler( + MessagingService messagingService, + RemotelyTriggeredResourceRegistry resourcesRegistry + ) { + this.messagingService = messagingService; + this.resourcesRegistry = resourcesRegistry; + } + + /** + * Starts the processor. + */ + public void start() { + messagingService.addMessageHandler(TxMessageGroup.class, (msg, sender, correlationId) -> { + if (msg instanceof CloseCursorsBatchMessage) { + processTxCleanup((CloseCursorsBatchMessage) msg); + } + }); + } + + public void stop() { + } + + private void processTxCleanup(CloseCursorsBatchMessage closeCursorsMessage) { + closeCursorsMessage.transactions().forEach(resourcesRegistry::close); + } Review Comment: Here we can process potentially huge batch of transactions (tracker allows max size of 10k), I an not sure it's a good idea to do this in network thread. What do you think about adding it to resource cleanup manager to close resources in background? On the other side, it's additional pressure on the heap, but network delay may be more critical -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
