[ https://issues.apache.org/jira/browse/TEPHRA-223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15876474#comment-15876474 ]
ASF GitHub Bot commented on TEPHRA-223: --------------------------------------- Github user chtyim commented on a diff in the pull request: https://github.com/apache/incubator-tephra/pull/37#discussion_r102284511 --- Diff: tephra-core/src/main/java/org/apache/tephra/manager/InvalidTxList.java --- @@ -0,0 +1,113 @@ +/* + * 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.tephra.manager; + +import it.unimi.dsi.fastutil.longs.LongArrayList; +import org.apache.tephra.TransactionManager; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import javax.annotation.concurrent.NotThreadSafe; + +/** + * This is an internal class used by the {@link TransactionManager} to store invalid transaction ids. + * This class uses both a list and an array to keep track of the invalid ids. The list is the primary + * data structure for storing the invalid ids. The array is populated lazily on changes to the list. + * The array is used to avoid creating a new array every time method {@link #toArray()} is invoked. + * + * This class is not thread safe and relies on external synchronization. TransactionManager always + * accesses an instance of this class after synchronization. + */ +@NotThreadSafe +public class InvalidTxList { + private static final long[] NO_INVALID_TX = { }; + + private final LongArrayList invalid = new LongArrayList(); --- End diff -- Better have the type as `LongList`. > Transactions started after a snapshot restore can have incorrect invalid > transaction list > ----------------------------------------------------------------------------------------- > > Key: TEPHRA-223 > URL: https://issues.apache.org/jira/browse/TEPHRA-223 > Project: Tephra > Issue Type: Bug > Components: core > Affects Versions: 0.5.0, 0.6.5, 0.7.0, 0.8.0-incubating, 0.9.0-incubating, > 0.10.0-incubating > Reporter: Poorna Chandra > Assignee: Poorna Chandra > Fix For: 0.12.0-incubating > > > Transaction Manager uses two datastructures to manage the invalid list - a > {{List}} and an {{array}}. All updates to invalid list happen to the > {{List}}, and the list is then sorted and copied over to the {{array}}. This > is an optimization done so as to not sort the invalid list every time a new > transaction is created. > However during a snapshot restore after the Transaction Manager starts up, > the invalid list gets correctly restored to the {{List}} but does not get > copied over to the {{array}}. This will lead to transactions started right > after a snapshot restore to have empty invalid list. This will make invalid > data to become visible to those transactions. > Since the {{List}} still contains the right invalid list, any update to the > invalid list - like invalidating a transaction, will restore the {{array}} > back to a good state. > Also compactions will still remove invalid data as expected since new > snapshots are searialized using the {{List}} -- This message was sent by Atlassian JIRA (v6.3.15#6346)