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

Fixed previous offset #7

Open
wants to merge 3 commits into
base: final-connector-ybdb
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private YugabyteDBOffsetContext(YugabyteDBConnectorConfig connectorConfig,
// sourceInfo.update(lsn, time, txId, null, sourceInfo.xmin());
sourceInfo.updateLastCommit(lastCommitLsn);
sourceInfoSchema = sourceInfo.schema();

Copy link
Collaborator

Choose a reason for hiding this comment

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

why extra space?

this.lastSnapshotRecord = lastSnapshotRecord;
if (this.lastSnapshotRecord) {
postSnapshotCompletion();
Expand All @@ -79,6 +79,8 @@ public YugabyteDBOffsetContext(Set<YugabyteDBOffsetContext> s,
this.sourceInfoSchema = sourceInfo.schema();
for (YugabyteDBOffsetContext context : s) {
if (context != null) {
this.lastCompletelyProcessedLsn = context.lastCompletelyProcessedLsn;
this.lastCommitLsn = context.lastCommitLsn;
LOGGER.debug("Populating the tabletsourceinfo" + context.getTabletSourceInfo());
if (context.getTabletSourceInfo() != null) {
this.tabletSourceInfo.putAll(context.getTabletSourceInfo());
Expand Down Expand Up @@ -273,7 +275,8 @@ public String toString() {
+ ", lastCommitLsn=" + lastCommitLsn
+ ", streamingStoppingLsn=" + streamingStoppingLsn
+ ", transactionContext=" + transactionContext
+ ", incrementalSnapshotContext=" + incrementalSnapshotContext + "]";
+ ", incrementalSnapshotContext=" + incrementalSnapshotContext
+ ", tabletSourceInfo=" + tabletSourceInfo + "]";
}

public OffsetState asOffsetState() {
Expand Down Expand Up @@ -333,7 +336,13 @@ private String readOptionalString(Map<String, ?> offset, String key) {
public YugabyteDBOffsetContext load(Map<String, ?> offset) {

LOGGER.debug("The offset being loaded in YugabyteDBOffsetContext.. " + offset);

OpId lastCompletelyProcessedLsn;
if(offset != null){
lastCompletelyProcessedLsn = OpId.valueOf((String) offset.get(YugabyteDBOffsetContext.LAST_COMPLETELY_PROCESSED_LSN_KEY));
Copy link
Collaborator

Choose a reason for hiding this comment

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

indentation?

}
else{
lastCompletelyProcessedLsn = new OpId(0, 0, null, 0, 0);
}
/*
* final OpId lsn = OpId.valueOf(readOptionalString(offset, SourceInfo.LSN_KEY));
* final OpId lastCompletelyProcessedLsn = OpId.valueOf(readOptionalString(offset,
Expand All @@ -355,9 +364,9 @@ public YugabyteDBOffsetContext load(Map<String, ?> offset) {
*/

return new YugabyteDBOffsetContext(connectorConfig,
new OpId(0, 0, null, 0, 0),
new OpId(0, 0, null, 0, 0),
new OpId(0, 0, null, 0, 0),
lastCompletelyProcessedLsn,
lastCompletelyProcessedLsn,
lastCompletelyProcessedLsn,
"txId", Instant.MIN, false, false,
TransactionContext.load(offset),
SignalBasedIncrementalSnapshotContext.load(offset));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public SnapshotResult<YugabyteDBOffsetContext> doExecute(
SnapshottingTask snapshottingTask)
throws Exception {
final RelationalSnapshotChangeEventSource.RelationalSnapshotContext<YugabyteDBPartition, YugabyteDBOffsetContext> ctx = (RelationalSnapshotChangeEventSource.RelationalSnapshotContext<YugabyteDBPartition, YugabyteDBOffsetContext>) snapshotContext;

// Connection connection = null;
try {
LOGGER.info("Snapshot step 1 - Preparing");
Expand Down Expand Up @@ -168,7 +167,7 @@ public SnapshotResult<YugabyteDBOffsetContext> doExecute(

// postSnapshot();
dispatcher.alwaysDispatchHeartbeatEvent(ctx.partition, ctx.offset);
return SnapshotResult.completed(ctx.offset);
return SnapshotResult.completed(previousOffset);
}
finally {
// rollbackTransaction(connection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ private void getChanges2(ChangeEventSourceContext context,
for (Pair<String, String> entry : tabletPairList) {
final String tabletId = entry.getValue();
offsetContext.initSourceInfo(tabletId, this.connectorConfig);
offsetContext.getSourceInfo(tabletId).updateLastCommit(offsetContext.lastCompletelyProcessedLsn());
Copy link
Collaborator

Choose a reason for hiding this comment

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

please take care of indentation!

}
LOGGER.debug("The init tabletSourceInfo is " + offsetContext.getTabletSourceInfo());

Expand Down