Thank you very much for answering my questions, for the second question, do
you have any plan to add this feature in Ratis?

Regards,
Alan

On Tue, Dec 18, 2018 at 10:53 AM Tsz Wo Sze <[email protected]> wrote:

> Hi Alan,
>
> 1. This is a WAL (Write Ahead Log) question, i.e. how a WAL prevents
> duplication.  You need to solve this problem even with a single server
> so that it is not specific to Ratis/Raft.  One way is to make the db
> transactions idempotent.  Another way to use a pair of begin-end
> transactions.
>
> 2. This is currently a missing feature in Ratis.
>
> Please feel free to send you questions to
> [email protected] (instead of dev). Thanks.
>
> Tsz-Wo
>
> On Thu, Dec 13, 2018 at 7:35 AM Alan WU <[email protected]> wrote:
> >
> > Hello developers,
> > It's nice to meet you, I'm glad to hear that you are building a
> middleware
> > of open source project about Raft protocol,  I've forked the code into my
> > code repository, I really appreciate your contribution to the open source
> > community.
> >
> > There are some questions made me confused
> >
> > 1. I created a class and extend to BaseStateMachine, and override the
> > method applyTransaction , below is the method code:
> >
> > @Override
> > public CompletableFuture<Message> applyTransaction(TransactionContext
> trx) {
> >     final LogEntryProto entry = trx.getLogEntry();
> >     ByteString data = entry.getSmLogEntry().getData();
> >     final long index = entry.getIndex();
> >     byte[] bytes = data.toByteArray();
> >     String log = new String(bytes,Charset.forName("UTF-8"));
> >     System.out.println("applyTransaction::"+index);
> >     if(replicationTask.executeTransaction(log)){
> >         updateLastAppliedTermIndex(entry.getTerm(), index);
> >         return CompletableFuture.completedFuture(Message.valueOf("ok"));
> >     }
> >     return CompletableFuture.completedFuture(Message.valueOf("failed"));
> > }
> >
> > My transaction is used to create or update a record into Mysql db, so the
> > entry log can be seen as a SQL bin log, so my question is, how to
> guarantee
> > my database record won't be duplicated when the machine is restarted and
> > then the snapshot replay.
> >
> > 2. how to physically delete the history logs when all machines SQL log is
> > executed successfully.
> >
> > Looking forward to your reply.
> >
> > Best regards,
> > Alan
>

Reply via email to