Skip to content

Commit

Permalink
Fixed issues after merging in elasticity branch changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dlmarion committed Oct 18, 2023
1 parent 804f1df commit f1070c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ public void flush(long tableFlushID) {
// in tablet reading and writing the tablets metadata.
if (lastTabletMetadata.getFlushId().orElse(-1) < tableFlushID) {
try (var tabletsMutator = getContext().getAmple().conditionallyMutateTablets()) {
var tablet = tabletsMutator.mutateTablet(extent)
var tablet = tabletsMutator.mutateTablet(extent, lastTabletMetadata.getPrevEndRow())
.requireLocation(Location.current(tabletServer.getTabletSession()))
.requireSame(lastTabletMetadata, ColumnType.PREV_ROW, ColumnType.FLUSH_ID);
.requireSame(lastTabletMetadata, ColumnType.FLUSH_ID);

tablet.putFlushId(tableFlushID);
tablet.putZooLock(context.getZooKeeperRoot(), getTabletServer().getLock());
Expand Down Expand Up @@ -1319,9 +1319,9 @@ public Optional<StoredTabletFile> updateTabletDataFile(long maxCommittedTime,
}

try (var tabletsMutator = getContext().getAmple().conditionallyMutateTablets()) {
var tablet = tabletsMutator.mutateTablet(extent)
var tablet = tabletsMutator.mutateTablet(extent, lastTabletMetadata.getPrevEndRow())
.requireLocation(Location.current(tabletServer.getTabletSession()))
.requireSame(lastTabletMetadata, ColumnType.PREV_ROW, ColumnType.TIME);
.requireSame(lastTabletMetadata, ColumnType.TIME);

Optional<StoredTabletFile> newFile = Optional.empty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,33 +782,37 @@ public void testFlushId() {

var tabletMeta1 = TabletMetadata.builder(e1).putFlushId(42L).build();
assertTrue(tabletMeta1.getFlushId().isPresent());
ctmi.mutateTablet(e1).requireAbsentOperation().requireSame(tabletMeta1, FLUSH_ID)
.putFlushId(43L).submit(tabletMetadata -> tabletMetadata.getFlushId().orElse(-1) == 43L);
ctmi.mutateTablet(e1, e1.prevEndRow()).requireAbsentOperation()
.requireSame(tabletMeta1, FLUSH_ID).putFlushId(43L)
.submit(tabletMetadata -> tabletMetadata.getFlushId().orElse(-1) == 43L);
var results = ctmi.process();
assertEquals(Status.REJECTED, results.get(e1).getStatus());
assertTrue(context.getAmple().readTablet(e1).getFlushId().isEmpty());

ctmi = new ConditionalTabletsMutatorImpl(context);
var tabletMeta2 = TabletMetadata.builder(e1).build(FLUSH_ID);
assertFalse(tabletMeta2.getFlushId().isPresent());
ctmi.mutateTablet(e1).requireAbsentOperation().requireSame(tabletMeta2, FLUSH_ID)
.putFlushId(43L).submit(tabletMetadata -> tabletMetadata.getFlushId().orElse(-1) == 43L);
ctmi.mutateTablet(e1, e1.prevEndRow()).requireAbsentOperation()
.requireSame(tabletMeta2, FLUSH_ID).putFlushId(43L)
.submit(tabletMetadata -> tabletMetadata.getFlushId().orElse(-1) == 43L);
results = ctmi.process();
assertEquals(Status.ACCEPTED, results.get(e1).getStatus());
assertEquals(43L, context.getAmple().readTablet(e1).getFlushId().getAsLong());

ctmi = new ConditionalTabletsMutatorImpl(context);
var tabletMeta3 = TabletMetadata.builder(e1).putFlushId(43L).build();
assertTrue(tabletMeta1.getFlushId().isPresent());
ctmi.mutateTablet(e1).requireAbsentOperation().requireSame(tabletMeta3, FLUSH_ID)
.putFlushId(44L).submit(tabletMetadata -> tabletMetadata.getFlushId().orElse(-1) == 44L);
ctmi.mutateTablet(e1, e1.prevEndRow()).requireAbsentOperation()
.requireSame(tabletMeta3, FLUSH_ID).putFlushId(44L)
.submit(tabletMetadata -> tabletMetadata.getFlushId().orElse(-1) == 44L);
results = ctmi.process();
assertEquals(Status.ACCEPTED, results.get(e1).getStatus());
assertEquals(44L, context.getAmple().readTablet(e1).getFlushId().getAsLong());

ctmi = new ConditionalTabletsMutatorImpl(context);
ctmi.mutateTablet(e1).requireAbsentOperation().requireSame(tabletMeta3, FLUSH_ID)
.putFlushId(45L).submit(tabletMetadata -> tabletMetadata.getFlushId().orElse(-1) == 45L);
ctmi.mutateTablet(e1, e1.prevEndRow()).requireAbsentOperation()
.requireSame(tabletMeta3, FLUSH_ID).putFlushId(45L)
.submit(tabletMetadata -> tabletMetadata.getFlushId().orElse(-1) == 45L);
results = ctmi.process();
assertEquals(Status.REJECTED, results.get(e1).getStatus());
assertEquals(44L, context.getAmple().readTablet(e1).getFlushId().getAsLong());
Expand Down

0 comments on commit f1070c3

Please sign in to comment.