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

IGNITE-23305 Get rid of client HybridTimestampTracker #4929

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

vldpyatkov
Copy link
Contributor

@vldpyatkov vldpyatkov requested a review from xtern December 20, 2024 10:55
@xtern xtern requested a review from korlov42 December 23, 2024 09:39
@@ -35,14 +35,14 @@
public class IgniteTransactionsImpl implements IgniteTransactions {
private final TxManager txManager;

private final HybridTimestampTracker observableTimestampTracker;
private final HybridTimestampTrackerImpl observableTimestampTracker;
Copy link
Contributor

Choose a reason for hiding this comment

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

let's use interface instead of implementation. Besides, there are number of methods which are not used anymore. Let's clean up IgniteTransactionsImpl

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this instance, the field can only be an instance of HybridTimestampTrackerImpl.
It is not worth overdoing with the use of interfaces.

Copy link
Contributor Author

@vldpyatkov vldpyatkov Dec 24, 2024

Choose a reason for hiding this comment

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

there are number of methods which are not used anymore

Good point.

@@ -362,7 +362,7 @@ public class TableManager implements IgniteTablesInternal, IgniteComponent {

private final LowWatermark lowWatermark;

private final HybridTimestampTracker observableTimestampTracker;
private final HybridTimestampTrackerImpl observableTimestampTracker;
Copy link
Contributor

Choose a reason for hiding this comment

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

let's use interface here and below. Please check this kind of changes everywhere in your patch

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 prefer to use a concrete implementation until the other is not needed.


case ClientOp.SQL_QUERY_META:
return ClientSqlQueryMetadataRequest.process(in, out, queryProcessor, resources);

case ClientOp.SQL_EXEC_BATCH:
return ClientSqlExecuteBatchRequest.process(in, out, queryProcessor, resources, igniteTransactions);
return ClientSqlExecuteBatchRequest.process(in, out, queryProcessor, resources).thenRun(() -> {
// TODO: IGNITE-24055 Observation timestamp must be updated only for DDL "CREATE TABLE..."
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you provide detailed description in the ticket which SQL statements requre passing back observable ts and which not, and fix the comment accordingly ?
I believe it's not only DDL "CREATE TABLE..."
This affects all places with the TODO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, I do not have a full list of SQL operations.
We should do an investigation before taking this issue for implementation. It is just a marker for the SQL team.

if (out != null) {
Object meta = out.meta();
if (out == null) {
return clockService.currentLong();
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't make sense to pass current server time on handshake to client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But we have tests where we consider it.
I mean the test where we make a schema (create table, zones) and then start a client, which has to execute a query over this schema.


if (tx == null) {
tx = igniteTransactions.beginImplicit(readOnly);
tx = startTx(out, txManager, null, true, readOnly);
Copy link
Contributor

Choose a reason for hiding this comment

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

In case of implicit transaction observable ts must be transferred from the client in the message.
It doesn't happen now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Observation timestamp is not necessary for the implicit transaction.
I will add a comment.

/**
* Hybrid timestamp tracker.
*/
public class HybridTimestampTrackerImpl implements HybridTimestampTracker {
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need this change. It brings a lot of modified files in PR without any profit.
Instead, change implementation in the following way:

public class HybridTimestampTracker {
    /** Timestamp. */
    private final AtomicLong timestamp = new AtomicLong(NULL_HYBRID_TIMESTAMP);
    
    private final Consumer<HybridTimestamp> updateTs;

    public HybridTimestampTracker() {
        this.updateTs = timestamp -> {
            long tsVal = HybridTimestamp.hybridTimestampToLong(ts);

            HybridTimestampTracker.this.timestamp.updateAndGet(x -> Math.max(x, tsVal));
        };
    }
    
    public HybridTimestampTracker(@Nullable HybridTimestamp currentTs, Consumer<HybridTimestamp> updateTs) {
        this.timestamp.set(currentTs.longValue());
        this.updateTs = updateTs;
    }

    public @Nullable HybridTimestamp get() {
        return HybridTimestamp.nullableHybridTimestamp(timestamp.get());
    }

    public void update(@Nullable HybridTimestamp ts) {
        updateTs.accept(ts);
    }
}

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