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

[fix] [txn] update txn status concurrently throw exception #20053

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TakaHiR07
Copy link
Contributor

@TakaHiR07 TakaHiR07 commented Apr 10, 2023

Motivation

When MLTransactionMetadataStore#updateTxnStatus concurrently, there is a case only one request succeed, other requests throw exception.

Modifications

If the newStatus == txnMeta.status(), it should not throw exception to client. Which is the same as

if (txnMetaListPair.getLeft().status() == newStatus) {
promise.complete(null);
return promise;
}

  1. judge "txnMetaListPair.getLeft().status() == newStatus" again after synchronize
  2. add test

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: TakaHiR07#4

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Apr 10, 2023
@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions bot added the Stale label May 13, 2023
@TakaHiR07
Copy link
Contributor Author

@congbobo184 can you help take a look of this problem?

@github-actions github-actions bot removed the Stale label May 31, 2023
Copy link
Contributor

@liangyepianzhou liangyepianzhou left a comment

Choose a reason for hiding this comment

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

Good catch!

@poorbarcode
Copy link
Contributor

@congbobo184 @liangyepianzhou

Is this PR similar to #19630?

@liangyepianzhou
Copy link
Contributor

liangyepianzhou commented Jun 7, 2023

@congbobo184 @liangyepianzhou

Is this PR similar to #19630?

The modification is similar to #19630, but the motivation is different.
The motivation for #19630 is try to commit a transaction which has been committed already.
In this case, the modification is invalid because the TxnMeta of the transaction is already deleted.

@liangyepianzhou
Copy link
Contributor

TxnStats is written by a single thread, so the update stats thread should also be single-threaded. I don't understand where the concurrency problem occurs. Can you point it out?

        CompletableFuture
                .runAsync(
                        () -> internalAsyncAddData(data, callback, ctx), singleThreadExecutorForWrite)
                .exceptionally(e -> {
                    log.warn("Execute 'internalAsyncAddData' fail", e);
                    return null;
                });

@TakaHiR07
Copy link
Contributor Author

TakaHiR07 commented Jun 8, 2023

TxnStats is written by a single thread, so the update stats thread should also be single-threaded. I don't understand where the concurrency problem occurs. Can you point it out?

TxnStatus is appended to txnLog by single thread, but the operation after thenAccept is executed in other thread. So it cause the concurrency problem.

return transactionLog.append(transactionMetadataEntry)
.thenAccept(position -> {
appendLogCount.increment();

@liangyepianzhou
Copy link
Contributor

TxnStatus is appended to txnLog by single thread, but the operation after thenAccept is executed in other thread. So it cause the concurrency problem.

The thenAccept will use the original thread instead of another thread, right?
Please take a look. @poorbarcode

@Technoboy- Technoboy- modified the milestones: 3.1.0, 3.2.0 Jul 31, 2023
@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants