Skip to content

Commit

Permalink
Notify fixes (#863)
Browse files Browse the repository at this point in the history
- Change notify reconnect to use a backoff
- Change unlisten to active on dispose of EmitterProcessor instead of longer processing chain
- Fix Hibernate trying to connect on startup to check if embedded database
- Fix incorrectly using EmitterProcessor
- Fix invalid json causing a reconnect

Signed-off-by: Steven Sheehy <[email protected]>
  • Loading branch information
steven-sheehy authored Jul 12, 2020
1 parent b78d15c commit 6a43e2d
Show file tree
Hide file tree
Showing 25 changed files with 32 additions and 26 deletions.
2 changes: 1 addition & 1 deletion charts/hedera-mirror-grpc/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
appVersion: 0.15.0-rc1
appVersion: 0.15.0-rc2
description: GRPC API for the Hedera Mirror Node
home: https://github.com/hashgraph/hedera-mirror-node
icon: https://camo.githubusercontent.com/cca6b767847bb8ca5c7059481ba13a5fc81c5938/68747470733a2f2f7777772e6865646572612e636f6d2f6c6f676f2d6361706974616c2d686261722d776f72646d61726b2e6a7067
Expand Down
2 changes: 1 addition & 1 deletion charts/hedera-mirror-importer/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
appVersion: 0.15.0-rc1
appVersion: 0.15.0-rc2
description: Hedera Mirror Importer downloads and validates file streams from the cloud and imports them into the database
home: https://github.com/hashgraph/hedera-mirror-node
icon: https://camo.githubusercontent.com/cca6b767847bb8ca5c7059481ba13a5fc81c5938/68747470733a2f2f7777772e6865646572612e636f6d2f6c6f676f2d6361706974616c2d686261722d776f72646d61726b2e6a7067
Expand Down
2 changes: 1 addition & 1 deletion charts/hedera-mirror-rest/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
appVersion: 0.15.0-rc1
appVersion: 0.15.0-rc2
description: REST API for the Hedera Mirror Node
home: https://github.com/hashgraph/hedera-mirror-node
icon: https://camo.githubusercontent.com/cca6b767847bb8ca5c7059481ba13a5fc81c5938/68747470733a2f2f7777772e6865646572612e636f6d2f6c6f676f2d6361706974616c2d686261722d776f72646d61726b2e6a7067
Expand Down
2 changes: 1 addition & 1 deletion charts/hedera-mirror/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
appVersion: 0.15.0-rc1
appVersion: 0.15.0-rc2
description: Hedera Mirror Node mirrors data from Hedera nodes and serves it via an API
home: https://github.com/hashgraph/hedera-mirror-node
icon: https://camo.githubusercontent.com/cca6b767847bb8ca5c7059481ba13a5fc81c5938/68747470733a2f2f7777772e6865646572612e636f6d2f6c6f676f2d6361706974616c2d686261722d776f72646d61726b2e6a7067
Expand Down
Binary file modified charts/hedera-mirror/charts/hedera-mirror-grpc-0.3.0.tgz
Binary file not shown.
Binary file modified charts/hedera-mirror/charts/hedera-mirror-importer-0.3.0.tgz
Binary file not shown.
Binary file modified charts/hedera-mirror/charts/hedera-mirror-rest-0.3.0.tgz
Binary file not shown.
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
- 5432:5432

grpc:
image: gcr.io/mirrornode/hedera-mirror-grpc:0.15.0-rc1
image: gcr.io/mirrornode/hedera-mirror-grpc:0.15.0-rc2
restart: unless-stopped
environment:
HEDERA_MIRROR_GRPC_DB_HOST: db
Expand All @@ -28,7 +28,7 @@ services:
- 5600:5600

importer:
image: gcr.io/mirrornode/hedera-mirror-importer:0.15.0-rc1
image: gcr.io/mirrornode/hedera-mirror-importer:0.15.0-rc2
restart: unless-stopped
environment:
HEDERA_MIRROR_IMPORTER_DATAPATH: /var/lib/hedera-mirror-importer
Expand All @@ -39,7 +39,7 @@ services:
- ./application.yml:/usr/etc/hedera-mirror-importer/application.yml

rest:
image: gcr.io/mirrornode/hedera-mirror-rest:0.15.0-rc1
image: gcr.io/mirrornode/hedera-mirror-rest:0.15.0-rc2
environment:
HEDERA_MIRROR_REST_DB_HOST: db
restart: unless-stopped
Expand Down
2 changes: 1 addition & 1 deletion hedera-mirror-coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>com.hedera</groupId>
<artifactId>hedera-mirror-node</artifactId>
<version>0.15.0-rc1</version>
<version>0.15.0-rc2</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion hedera-mirror-datagenerator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>com.hedera</groupId>
<artifactId>hedera-mirror-node</artifactId>
<version>0.15.0-rc1</version>
<version>0.15.0-rc2</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion hedera-mirror-grpc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>com.hedera</groupId>
<artifactId>hedera-mirror-node</artifactId>
<version>0.15.0-rc1</version>
<version>0.15.0-rc2</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
import io.vertx.pgclient.pubsub.PgChannel;
import io.vertx.pgclient.pubsub.PgSubscriber;
import java.time.Duration;
import java.util.Objects;
import javax.inject.Named;
import lombok.extern.log4j.Log4j2;
import reactor.core.publisher.EmitterProcessor;
import reactor.core.publisher.Flux;
import reactor.core.publisher.FluxSink;
import reactor.core.scheduler.Schedulers;
import reactor.util.retry.Retry;

Expand Down Expand Up @@ -60,7 +62,7 @@ public NotifyingTopicListener(DbProperties dbProperties, ListenerProperties list
PgSubscriber subscriber = PgSubscriber.subscriber(vertx, connectOptions)
.reconnectPolicy(retries -> {
log.warn("Attempting reconnect");
return frequency.toMillis();
return frequency.toMillis() * Math.min(retries, 4);
});

// Connect asynchronously to avoid crashing the application on startup if the database is down
Expand All @@ -76,9 +78,9 @@ public NotifyingTopicListener(DbProperties dbProperties, ListenerProperties list
topicMessages = Flux.defer(() -> listen())
.publishOn(Schedulers.boundedElastic())
.map(this::toTopicMessage)
.filter(Objects::nonNull)
.name("notify")
.metrics()
.doFinally(s -> unlisten())
.doOnError(t -> log.error("Error listening for messages", t))
.retryWhen(Retry.backoff(Long.MAX_VALUE, frequency).maxBackoff(frequency.multipliedBy(4L)))
.share();
Expand All @@ -98,7 +100,8 @@ private boolean filterMessage(TopicMessage message, TopicMessageFilter filter) {

private Flux<String> listen() {
EmitterProcessor<String> emitterProcessor = EmitterProcessor.create();
channel.handler(json -> emitterProcessor.onNext(json));
FluxSink<String> sink = emitterProcessor.sink().onDispose(this::unlisten);
channel.handler(json -> sink.next(json));
log.info("Listening for messages");
return emitterProcessor;
}
Expand All @@ -112,7 +115,9 @@ private TopicMessage toTopicMessage(String payload) {
try {
return objectMapper.readValue(payload, TopicMessage.class);
} catch (Exception ex) {
throw new RuntimeException(ex);
// Discard invalid messages. No need to propagate error and cause a reconnect.
log.error("Error parsing message {}", payload, ex);
return null;
}
}
}
1 change: 1 addition & 0 deletions hedera-mirror-grpc/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ spring:
properties:
hibernate.criteria.literal_handling_mode: BIND # Ensure Criteria API queries use bind parameters and not literals
hibernate.generate_statistics: true
hibernate.hbm2ddl.auto: none
test:
database:
replace: NONE
2 changes: 1 addition & 1 deletion hedera-mirror-importer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>com.hedera</groupId>
<artifactId>hedera-mirror-node</artifactId>
<version>0.15.0-rc1</version>
<version>0.15.0-rc2</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion hedera-mirror-protobuf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>com.hedera</groupId>
<artifactId>hedera-mirror-node</artifactId>
<version>0.15.0-rc1</version>
<version>0.15.0-rc2</version>
</parent>

<properties>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion hedera-mirror-rest/monitoring/monitor_apis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hedera-mirror-monitor",
"version": "0.15.0-rc1",
"version": "0.15.0-rc2",
"description": "Hedera Mirror Node Monitor",
"main": "server.js",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion hedera-mirror-rest/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion hedera-mirror-rest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hedera-mirror-rest",
"version": "0.15.0-rc1",
"version": "0.15.0-rc2",
"description": "Hedera Mirror Node REST API",
"main": "server.js",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion hedera-mirror-rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>com.hedera</groupId>
<artifactId>hedera-mirror-node</artifactId>
<version>0.15.0-rc1</version>
<version>0.15.0-rc2</version>
</parent>

<build>
Expand Down
2 changes: 1 addition & 1 deletion hedera-mirror-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>com.hedera</groupId>
<artifactId>hedera-mirror-node</artifactId>
<version>0.15.0-rc1</version>
<version>0.15.0-rc2</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
app.kubernetes.io/name: test
restartPolicy: Never
containers:
- image: gcr.io/mirrornode/hedera-mirror-test:0.15.0-rc1
- image: gcr.io/mirrornode/hedera-mirror-test:0.15.0-rc2
name: test
env:
- name: testProfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
app.kubernetes.io/name: test
restartPolicy: Never
containers:
- image: gcr.io/mirrornode/hedera-mirror-test:0.15.0-rc1
- image: gcr.io/mirrornode/hedera-mirror-test:0.15.0-rc2
name: test
env:
- name: testProfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
app.kubernetes.io/name: test
restartPolicy: Never
containers:
- image: gcr.io/mirrornode/hedera-mirror-test:0.15.0-rc1
- image: gcr.io/mirrornode/hedera-mirror-test:0.15.0-rc2
name: test
env:
- name: testProfile
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.hedera</groupId>
<artifactId>hedera-mirror-node</artifactId>
<version>0.15.0-rc1</version>
<version>0.15.0-rc2</version>
<description>Hedera Mirror Node mirrors data from Hedera nodes and serves it via an API</description>
<inceptionYear>2019</inceptionYear>
<modelVersion>4.0.0</modelVersion>
Expand Down

0 comments on commit 6a43e2d

Please sign in to comment.