Skip to content

Commit

Permalink
fix: Don't migrate twice now we have same store
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Roberts <ryan@blockchaintp.com>
  • Loading branch information
ryan-s-roberts committed Sep 28, 2021
1 parent a189922 commit fa40be0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;

import kr.pe.kwonnam.slf4jlambda.LambdaLogger;
Expand All @@ -33,7 +32,6 @@ public final class CommitHighwaterMark {
private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
private static final LambdaLogger LOG = LambdaLoggerFactory.getLogger(CommitHighwaterMark.class);
private final ConcurrentSkipListSet<Long> open = new ConcurrentSkipListSet<>();
private final AtomicLong highWatermark = new AtomicLong();

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ public Future<SubmissionResult> commit(final String correlationId, final Raw.Env
}
return SubmissionResult.Acknowledged$.MODULE$;
})).collect(Collectors.toList());

try {
var blockedRes = commits.stream().findFirst().get().get();
return Future.successful(blockedRes);
} catch (InterruptedException | ExecutionException e) {
return Future.successful(SubmissionResult.NotSupported$.MODULE$);
Thread.currentThread().interrupted();
return Future.successful(new SubmissionResult.InternalError(e.toString()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public PostgresStoreBuilder(final String theUrl) {
* @return A configured builder.
*/
public PostgresStoreBuilder migrate() {
var flyway = Flyway.configure().locations("classpath:migrations/store", "classpath:migrations/txlog")
.dataSource(url, "", "").load();
var flyway = Flyway.configure().locations("classpath:migrations/store").dataSource(url, "", "").load();

flyway.migrate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ object Main extends App {
.retrying(3)
.build()

/// Only migrate the
val txLog = PostgresTransactionLog
.fromUrl(config.extra.txLogStore)
.migrate()
Expand Down
25 changes: 13 additions & 12 deletions qldb/src/main/scala/com/blockchaintp/daml/qldb/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ object Main extends App {
"daml-on-qldb",
new LedgerFactory((config: Config[ExtraConfig], builder: ParticipantBuilder[QldbIdentifier, QldbAddress]) => {

val txBlobStore = PostgresStore
.fromUrl(config.extra.txLogStore)
.migrate()
.retrying(3)
.build()

val stateBlobStore = PostgresStore
.fromUrl(config.extra.txLogStore)
.retrying(3)
.build()

if (config.extra.createAws) {
try {
val qldbClient = QldbClient.builder
Expand All @@ -80,18 +91,6 @@ object Main extends App {
}
}

val txBlobStore = PostgresStore
.fromUrl(config.extra.txLogStore)
.migrate()
.retrying(3)
.build()

val stateBlobStore = PostgresStore
.fromUrl(config.extra.txLogStore)
.migrate()
.retrying(3)
.build()

val sessionBuilder = QldbSessionClient.builder
.region(Region.of(config.extra.region))
.credentialsProvider(DefaultCredentialsProvider.builder.build())
Expand All @@ -115,6 +114,8 @@ object Main extends App {
val stateStore = SplitStore
.fromStores(stateQldbStore, stateBlobStore)
.verified(true)
.withCaching(1000)
.withS3Index(false)
.build()

val qldbTransactionLog = QldbTransactionLog
Expand Down

0 comments on commit fa40be0

Please sign in to comment.