Skip to content

CASSANDRA-14618 Create fqltool replay command#255

Closed
jasobrown wants to merge 8 commits intoapache:trunkfrom
krummas:marcuse/14618
Closed

CASSANDRA-14618 Create fqltool replay command#255
jasobrown wants to merge 8 commits intoapache:trunkfrom
krummas:marcuse/14618

Conversation

@jasobrown
Copy link
Contributor

No description provided.

Copy link
Contributor Author

@jasobrown jasobrown left a comment

Choose a reason for hiding this comment

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

I'm half way done with the review, so posting what I have now.

@Option(title = "use", name = {"--use"}, description = "Connect to the cluster(s) using this keyspace.")
private String useKeyspace;

@Option(title = "legacy", name = {"--legacyfiles"}, description = "If the FQL files don't contain keyspace information.")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this flag necessary post CASSANDRA-14656?

If it is needed, a minor nit cleanup to the description: "A flag to indicate if the FQL files do not contain keyspace information."

Copy link
Member

Choose a reason for hiding this comment

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

no we don't need this here since full query logs have not really been released yet, I'll remove it

Copy link
Member

Choose a reason for hiding this comment

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

and yes, at some point we should add versioning to the full query logs

@Override
public void run()
{
try
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need parameter checking here? For example, what if i set notargetHosts?

queries.clear();
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

petty nit: superfluous blank lines

}
catch (Throwable t)
{
out.println("USE "+query.keyspace+" failed: "+t.getMessage());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

petty nit: spacing around the + signs.

}
catch (Throwable t)
{
out.println("QUERY " + query +" got exception: "+t.getMessage());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

petty nit: spacing around the + signs.

@Option(title = "debug", name = {"--debug"}, description = "Debug mode, print all queries executed.")
private boolean debug;

@Option(title = "use", name = {"--use"}, description = "Connect to the cluster(s) using this keyspace.")
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 entirely clear to me. The user can state which keyspace to initially connect to, but then we'll switch the keyspaces on -demand in QueryReplayer.replayer(). What is the intent with the use field?

Copy link
Member

Choose a reason for hiding this comment

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

this was a left over from before we had keyspace in the full query logs, removed


public class FQLQueryIterator extends AbstractIterator<FQLQuery>
{
private final PriorityQueue<FQLQuery> pq;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please add a small comment here as to why a PriorityQueue ("so we can sort the entries by timestamp of the query in logs, not just the order in the file"). This would just be a nice, quick little helper.

return 1;

Batch otherBatch = (Batch) other;
if (queries.size() != otherBatch.queries.size())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only the length of of the queries lists are compared, not the actual contents of the queries lists. (Single.compareTo() compares the query strings).

Copy link
Member

Choose a reason for hiding this comment

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

right below this we iterate over the Single-queries and compare them one-by-one

{
private final ExecutorService es = Executors.newFixedThreadPool(1);
private final Iterator<List<FQLQuery>> queryIterator;
private final List<String> targetHosts;
Copy link
Member

Choose a reason for hiding this comment

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

This variable is unused. Its only used in the constructor.

if (query.keyspace != null && !query.keyspace.equals(session.getLoggedKeyspace()))
{
if (debug)
{
Copy link
Member

Choose a reason for hiding this comment

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

Single statement blocks do not require braces.

{
if (debug)
{
out.println(String.format("Switching keyspace from %s to %s", session.getLoggedKeyspace(), query.keyspace));
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why not use out.printf instead?

}
catch (Throwable t)
{
out.println("USE "+query.keyspace+" failed: "+t.getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

Nit: spacing

}

Timer timer = metrics.timer("queries");
if (timer.getCount() % 5000 == 0)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to choose 5000? Also, it would be better if it were constant and not a magic number.

{
StringBuilder sb = new StringBuilder("batch: ").append(batchType).append('\n');
for (Single q : queries)
{
Copy link
Member

Choose a reason for hiding this comment

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

Redundant braces for a single statement block.

values.add(subValues);
int numSubValues = in.int32();
for (int zz = 0; zz < numSubValues; zz++)
{
Copy link
Member

Choose a reason for hiding this comment

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

Redundant braces

{
StringBuilder sb = new StringBuilder();
if (cd == null)
{
Copy link
Member

Choose a reason for hiding this comment

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

Redundant braces


import com.google.common.annotations.VisibleForTesting;

import com.datastax.driver.core.ResultSet;
Copy link
Member

Choose a reason for hiding this comment

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

Unused import.

private final ChronicleQueue queryStoreQueue;
private final ExcerptAppender queryStoreAppender;
private final Set<Integer> finishedHosts = new HashSet<>();
private final File queryFilePath;
Copy link
Member

Choose a reason for hiding this comment

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

Unused variable.

Copy link
Contributor Author

@jasobrown jasobrown left a comment

Choose a reason for hiding this comment

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

another set of comments

List<ResultHandler.ComparableDefinition> def1 = asList();
List<ResultHandler.ComparableDefinition> def2 = o.asList();

for (int j = 0; j < def1.size(); j++)
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 you can do return asList().equals(o.asList()) instead of the for loop. (j.u.AbstractList.equals() basically does that)


boolean equal = true;
List<ResultHandler.ComparableDefinition> refDefs = cds.get(0).asList();
for (int i = 1; i < cds.size(); i++)
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 this might overlog. If you have greater than two elements in cds, and the first element (refDefs) differs from the rest of cds, the full log entry (via handleColumnDefMismatch()) will be printed n - 1 times. This is because handleColumnDefMismatch() prints the entire cds


ResultHandler.ComparableRow ref = rows.get(0);
boolean equal = true;
for (int i = 1; i < rows.size(); i++)
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 this might overlog. If you have greater than two elements in rows, and the first element (ref) differs from the rest of rows, the full log entry (via handleMismatch()) will be printed n - 1 times. This is because handleMismatch() prints the entire rows.

blambov pushed a commit to blambov/cassandra that referenced this pull request Oct 1, 2021
@smiklosovic smiklosovic changed the title Marcuse/14618 CASSANDRA-14618 Create fqltool replay command Mar 16, 2022
blambov pushed a commit to blambov/cassandra that referenced this pull request Mar 21, 2022
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.

4 participants