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

Transactions are applied on tablets without intents #2070

Closed
JDNdeveloper opened this issue Aug 15, 2019 · 0 comments
Closed

Transactions are applied on tablets without intents #2070

JDNdeveloper opened this issue Aug 15, 2019 · 0 comments
Assignees
Labels
area/docdb YugabyteDB core features

Comments

@JDNdeveloper
Copy link
Contributor

If you run the following SQL you will see two warning messages in the log.

SQL:

drop table if exists t;
create table t (k int primary key);
begin;
insert into t values (1);
select * from t where k = 2;
end;

Example warning messages:

W0814 18:31:58.293745 11289 transaction_participant.cc:1195] T 092c84b65a1d4cbaa44b7acc3a426e88 P 465bbc7ce57d438290cbc564c227c27a: Transaction not found: 3d5c46af-fa9c-4de5-a321-09d430ce6c9d, for: pre apply
W0814 18:31:58.293778 11289 transaction_participant.cc:1008] T 092c84b65a1d4cbaa44b7acc3a426e88 P 465bbc7ce57d438290cbc564c227c27a: Apply of unknown transaction: { transaction_id: 3d5c46af-fa9c-4de5-a321-09d430ce6c9d op_id: term: 1 index: 10062 commit_ht: { physical: 1565807518269905 logical: 16 } log_ht: { physical: 1565807518271659 logical: 3 } status_tablet: 5e697f9ed57046b4b9808d66d81fcc71 }

The warning message is caused by missing metadata on the tablet, which in turn is caused by the tablet never having intents written for the transaction. We should not be applying intents on tablets that do not actually contain intents for the given transaction.

In order to repro you simply need to perform a non-serializable read on a tablet that is not written to in the transaction. However, there is an optimization in the YB-PG client to not start a new distributed transaction until a write is actually performed, so you must first perform a write, and then you can perform the read on a different tablet which will repro the issue. We do not have this problem with serializable reads as they write read intents, so apply/cleanup should still be performed on these tablets.

Fixing this issue by not applying intents on these tablets will get rid of the warning message, but will also have the benefit of avoiding extraneous RPCs and minimizing the number of tablets the transaction coordinator (i.e. status tablet) has to wait for in both Apply and Cleanup.

@JDNdeveloper JDNdeveloper added the area/docdb YugabyteDB core features label Aug 15, 2019
@JDNdeveloper JDNdeveloper self-assigned this Aug 15, 2019
JDNdeveloper added a commit that referenced this issue Sep 7, 2019
Summary:
Currently transactions are applied on all tablets (both read and write), even if the tablet does not contain intents. This leads to an `Apply of unknown transaction` warning log message on a tablet that was only read from in a transaction when the transaction coordinator attempts to apply intents on it. It also adds superfluous RPCs between the transaction coordinator and tablets that don't actually need to be involved in this stage of the the transaction, and increases the number of tablets the transaction coordinator has to wait for during Apply/Cleanup.

This change makes it so we only pass tablets with intents written in the RPCs for Apply/Abort.

Test Plan:
Added new C++ test case to verify we don't apply on tablets without intents written.

Manually verified that `Apply of unknown transaction` message is no longer seen on SQL statements that reliably repro the issue without the change.

Reviewers: mikhail, sergei

Reviewed By: sergei

Subscribers: bogdan, ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D7078
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docdb YugabyteDB core features
Projects
None yet
Development

No branches or pull requests

1 participant