Skip to content

Commit

Permalink
(autoinc) avoid duplicated auto inc when role of fe changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dataroaring committed Jun 27, 2024
1 parent 9990181 commit c92e129
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.doris.common.io.Writable;
import org.apache.doris.persist.AutoIncrementIdUpdateLog;
import org.apache.doris.persist.EditLog;
import org.apache.doris.persist.gson.GsonPostProcessable;
import org.apache.doris.persist.gson.GsonUtils;

import com.google.common.base.Preconditions;
Expand All @@ -34,7 +35,7 @@
import java.io.DataOutput;
import java.io.IOException;

public class AutoIncrementGenerator implements Writable {
public class AutoIncrementGenerator implements Writable, GsonPostProcessable {
private static final Logger LOG = LogManager.getLogger(AutoIncrementGenerator.class);

public static final long NEXT_ID_INIT_VALUE = 1;
Expand Down Expand Up @@ -102,4 +103,10 @@ public void write(DataOutput out) throws IOException {
public static AutoIncrementGenerator read(DataInput in) throws IOException {
return GsonUtils.GSON.fromJson(Text.readString(in), AutoIncrementGenerator.class);
}

@Override
public void gsonPostProcess() throws IOException {
nextId = batchEndId;
}

}

0 comments on commit c92e129

Please sign in to comment.