Skip to content

Commit

Permalink
Merge pull request #1537 from thehyve/mv-refresh-start
Browse files Browse the repository at this point in the history
Added env var to control materialized views refresh on Saturn start
  • Loading branch information
tgreenwood authored Jul 16, 2024
2 parents 8105a17 + 7133329 commit efd7836
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3320,7 +3320,7 @@ To address this issue, materialized views are used for enhanced performance.
There are two types of materialized views: one for denormalized data, which includes the view ID and attribute data of Set/TermSet types, and another for joined views.
For each joined view, there is one corresponding join materialized view (as specified in the views.yaml config).

Materialized views are refreshed during database reindexing, on Saturn initialization stage and metadata updates, provided that the doViewsUpdate flag is set to true in the metadata endpoints. The refresh is performed concurrently what allows for the system to be available during the update providing the old version of data until the new one is ready.
Materialized views are refreshed during database reindexing, on Saturn initialization stage and metadata updates, provided that the doViewsUpdate flag is set to true in the metadata endpoints. The refresh is performed concurrently what allows for the system to be available during the update providing the old version of data until the new one is ready. To skip materialized views refresh on Saturn initialization stage, update the Saturn ConfigMap setting false value to `viewDatabase.mvRefreshOnStartRequired`.

==== Extra file storage

Expand Down
1 change: 1 addition & 0 deletions charts/fairspace/templates/project/configmap-saturn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ data:
blobStorePath: "/data/saturn/files/blobs"
viewDatabase:
enabled: true
mvRefreshOnStartRequired: true
features:
{{ toYaml .Values.fairspace.features | indent 6 }}
{{ if has "ExtraStorage" .Values.fairspace.features }}
Expand Down
1 change: 1 addition & 0 deletions projects/saturn/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ viewDatabase:
autoCommit: false
maxPoolSize: 50
connectionTimeout: 1000
mvRefreshOnStartRequired: true
search:
pageRequestTimeout: 10000
countRequestTimeout: 60000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public static class ViewDatabase {
public int maxPoolSize = 50;
public long connectionTimeout = 1000;
public boolean autoCommit = false;
public boolean mvRefreshOnStartRequired = true;
}

public static class ExtraStorage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.zaxxer.hikari.HikariDataSource;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import io.fairspace.saturn.config.Config;
Expand All @@ -33,7 +32,6 @@
@Slf4j
public class ViewStoreClientFactory {

@Getter
private final MaterializedViewService materializedViewService;

public ViewStoreClient build() throws SQLException {
Expand Down Expand Up @@ -82,7 +80,11 @@ public ViewStoreClientFactory(ViewsConfig viewsConfig, Config.ViewDatabase viewD
createOrUpdateView(view);
}
materializedViewService = new MaterializedViewService(dataSource, configuration, search.maxJoinItems);
materializedViewService.createOrUpdateAllMaterializedViews();
if (viewDatabase.mvRefreshOnStartRequired) {
materializedViewService.createOrUpdateAllMaterializedViews();
} else {
log.warn("Skipping materialized view refresh on start");
}
}

public Connection getConnection() throws SQLException {
Expand Down

0 comments on commit efd7836

Please sign in to comment.