Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To improve accord interoperability test coverage, need to extend the harry model domain to handle more possible CQL states #3785

Closed
wants to merge 72 commits into from

Conversation

dcapwell
Copy link
Contributor

No description provided.

@@ -536,7 +536,7 @@ protected ByteBuffer getValue(TableMetadata metadata, DecoratedKey partitionKey,
return row.clustering().bufferAt(column.position());
default:
Cell<?> cell = row.getCell(column);
return cell == null ? null : cell.buffer();
return cell == null || cell.isTombstone() || !cell.isLive(nowInSec) ? null : cell.buffer();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backport

commit 4fc8bb29fcda935728d8863a4499fa0e9d924b82
Author: Sunil Ramchandra Pawar <[email protected]>
Date:   Tue Jan 7 08:58:48 2025 -0800

    IndexOutOfBoundsException when accessing partition where the column was deleted

    patch by Sunil Ramchandra Pawar; reviewed by Caleb Rackliffe, David Capwell for CASSANDRA-20108

as these tests detect this issue

import accord.utils.Property;
import org.apache.cassandra.service.consensus.TransactionalMode;

public class AccordInteropSingleNodeTableWalkTest extends SingleNodeTableWalkTest
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think im going to drop all Interop tests for now as they are all broken... Ariel has a patch in-flight to fix known issues... so rather than blocking this patch its prob best to just skip testing accord for now...

@@ -223,7 +232,7 @@ private RowState updateRowState(RowState currentState, IntFunction<Bijections.Bi

assert lts >= currentState.lts[i] : String.format("Out-of-order LTS: %d. Max seen: %s", lts, currentState.lts[i]); // sanity check; we're iterating in lts order

if (currentState.lts[i] == lts)
if (lts != MagicConstants.NO_TIMESTAMP && currentState.lts[i] == lts)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ast tests down track timestamps so this would always hit this branch causing test failures... needed to disable this logic when doing a write and just assume that the write is newer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"down track"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, bad sentence.

the ast tests in this PR do not track timestamps, they rely on server to calculate them. The existing logic expects harry to own the timestamps and update the lts, so i need a way to opt-out of this behavior; hence this change.

When the caller defines the lts as NO_TIMESTAMP that tells harry to just accept the write and override, rather than try to deal with timestamp conflicts

@@ -2554,6 +2554,36 @@ public void filteringOnStaticColumnTest() throws Throwable
});
}

@Test
public void filteringOnDeletedStaticColumnValue() throws Throwable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

part of

commit 4fc8bb29fcda935728d8863a4499fa0e9d924b82
Author: Sunil Ramchandra Pawar <[email protected]>
Date:   Tue Jan 7 08:58:48 2025 -0800

    IndexOutOfBoundsException when accessing partition where the column was deleted

    patch by Sunil Ramchandra Pawar; reviewed by Caleb Rackliffe, David Capwell for CASSANDRA-20108

@@ -45,4 +55,42 @@ public void dnsDomainName()
{
qt().forAll(Generators.DNS_DOMAIN_NAME).checkAssert(InternetDomainName::from);
}

@Test
public void asciiDeterministic()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I found a deterministic issue with text but it ended up being an issue with IntelliJ displaying texts... these tests didn't solve any problem but did tell me that could be the issue...

by default text types now display a descriptor rather than the raw text, and lets you override and show the text with a flag... one issue is that the text displayed by IntelliJ might not be the exact string which can make repos harder....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i finally found the issue... when the utf-8 strings have control chars this can cause intellij to produce bad output... I added logic to convert those to escaped chars so the string output is safe. This also makes it more clear what chars are present as could be anything


import org.agrona.collections.Object2IntHashMap;

public class ImmutableUniqueList<T> extends AbstractList<T> implements RandomAccess
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java doesn't allow a List to also be a Set as they have method conflicts... so this List has the same properties of a Set but also maintain the insertion order dependent properties of List.

LinkedHashSet wasn't enough as the accesses pattern of index -> Value was cumbersome...

@aweisberg aweisberg self-requested a review January 22, 2025 21:00
import org.apache.cassandra.distributed.Cluster;
import org.apache.cassandra.service.consensus.TransactionalMode;

public class MultiNodeTableWalkTest extends SingleNodeTableWalkTest
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is currently not stable.... filed 3 tickets last night due to this test...

Copy link
Contributor

@aweisberg aweisberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing really earth shattering found.

else
{
NavigableSet<Clustering<ByteBuffer>> clusteringKeys = partition.clusteringKeys();
Clustering<ByteBuffer> clusteringKey = rs.pickOrderedSet(clusteringKeys);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ranges of clustering keys or is that not a priority RN because Accord doesn't interact with clustering keys much?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't ranges. We have selected a partition we wish to query, we look at all the clustering keys (aka rows) present in the partition, and we select one of them.

The goal of this else block is to pick a "row" to query

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my suggestion was to add ranges of clustering keys, not implying that it currently does that. We can call it out of scope for this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we actually had range support, and between... i dropped from this PR but its in #3844

the big issue is the existence of bugs on trunk.

Ill leave a TODO to add partition restricted clustering key filter command... WHERE pk=? and ck BETWEEN ? AND ?

@@ -223,7 +232,7 @@ private RowState updateRowState(RowState currentState, IntFunction<Bijections.Bi

assert lts >= currentState.lts[i] : String.format("Out-of-order LTS: %d. Max seen: %s", lts, currentState.lts[i]); // sanity check; we're iterating in lts order

if (currentState.lts[i] == lts)
if (lts != MagicConstants.NO_TIMESTAMP && currentState.lts[i] == lts)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"down track"?

Copy link
Contributor

@aweisberg aweisberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 TY only thing left is adding that comment like you said

@@ -77,4 +78,24 @@ public static List<InetSocketAddress> buildContactPoints(ICluster<? extends IIns
.map(ClusterUtils::getNativeInetSocketAddress)
.collect(Collectors.toList());
}

public static ConsistencyLevel toDriverCL(org.apache.cassandra.distributed.api.ConsistencyLevel cl)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used anymore. This was moved out of StatefulASTBase. In trunk i have a test to repo a history, so had to refactor that out

neededPks.addAll(partitionColumns);
}

public static List<ColumnMetadata> safeColumns(TableMetadata metadata)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to allColumnsInSelectOrder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you had the same comment with ASTGenerators.safeColumns... let me unify this stuff

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushed this to TableMetadata and removed this function and the one in ASTGenerators

}
}
protected static final EnumSet<KnownIssue> IGNORED_ISSUES = EnumSet.allOf(KnownIssue.class);
protected static boolean CQL_DEBUG_APPLY_OPERATOR = false;
Copy link
Contributor

@aweisberg aweisberg Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? Does it evaluate expressions before logging them to simplify? Maybe add a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ill add a comment... this is only something i understand =D

So, we generate stuff like 4 + 4 but when things fail you have the resolved value of 8. When you look at the history you can't use grep to filter for 8 as 4 + 4 will get filtered out... this option will change the history to "apply" or "resolve" the operator so it shows 8 instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushed this doc

    /**
     * mutations and selects will use operators (eg. {@code 4 + 4}, the + operator), and this will be reflected in the history output.
     *
     * When an issue is found its common to filter out insertions to different partitions/rows but this can become a problem
     * as the issue is for {@code pk=8} but the insert is to {@code 4 + 4}!
     *
     * Setting this to {@code true} will cause all operators to be "applied" or "executored" and the CQL in the history
     * will be the output (eg. {@code 4 + 4 } is replaced with {@code 8}).
     */
    protected static boolean CQL_DEBUG_APPLY_OPERATOR = false;

@dcapwell
Copy link
Contributor Author

dcapwell commented Feb 1, 2025

merged

@dcapwell dcapwell closed this Feb 1, 2025
@dcapwell dcapwell deleted the CASSANDRA-20156 branch February 1, 2025 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants