Skip to content

Commit

Permalink
Merge branch '7.4' into 7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
at055612 committed Jun 17, 2024
2 parents 5252429 + af74b95 commit 4ecba66
Show file tree
Hide file tree
Showing 48 changed files with 1,307 additions and 362 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ DO NOT ADD CHANGES HERE - ADD THEM USING log_change.sh
~~~


* Fix verification of the `signer` key in the JWS headers when authentication is handled by an AWS load balancer. If you use AWS load balancers for authentication you must add the partial ARN(s) of your load balancer(s) to the property `stroom.security.authentication.openId.expectedSignerPrefixes`.

* Issue **#4313** : Add debug for authentication exceptions.

* Issue **#4322** : Fix Feed Doc Cache entry invalidation when a new feed is created.

* Add debug logging to HttpAppender.

* Issue **#4306** : Fix inability to update config props that have previously been set to a non-default and then back to a default value.

* Issue **#2897** : Add more debug logging to the reference lookup code.

* Issue **#4307** : Fix stuck search.

* Issue **#4303** : Change DSParser to catch and handle StackOverflowError as an ERROR and with a better message.

* Issue **#4281** : Fix recent items dialog throwing an error when there are favourites in the explorer tree.


## [v7.5-beta.1] - 2024-06-04

* Issue **#3989** : Improve pause behaviour in dashboards and general presentation of `busy` state throughout UI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ appConfig:
- "openid"
clientId: null
clientSecret: null
expectedSignerPrefixes: []
formTokenRequest: true
identityProviderType: "INTERNAL_IDP"
issuer: null
Expand Down
1 change: 1 addition & 0 deletions stroom-config/stroom-config-global-impl-db/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies {
testImplementation project(':stroom-test-common')

testImplementation libs.assertj_core
testImplementation libs.guice_extension
testImplementation libs.junit_jupiter_api

testRuntimeOnly libs.junit_jupiter_engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
import stroom.config.impl.db.jooq.tables.records.ConfigRecord;
import stroom.db.util.GenericDao;
import stroom.db.util.JooqUtil;
import stroom.util.NullSafe;
import stroom.util.exception.DataChangedException;
import stroom.util.logging.LambdaLogger;
import stroom.util.logging.LambdaLoggerFactory;
import stroom.util.logging.LogUtil;
import stroom.util.shared.PropertyPath;

import jakarta.inject.Inject;
import org.jooq.DSLContext;
import org.jooq.Record;
import org.jooq.Record1;
import org.jooq.impl.DSL;

import java.util.List;
import java.util.Objects;
Expand All @@ -23,6 +29,8 @@

class ConfigPropertyDaoImpl implements ConfigPropertyDao {

private static final LambdaLogger LOGGER = LambdaLoggerFactory.getLogger(ConfigPropertyDaoImpl.class);

private static final int TRACKER_ID = 1;

private static final Function<Record, ConfigProperty> RECORD_TO_CONFIG_PROPERTY_MAPPER = record -> {
Expand Down Expand Up @@ -96,9 +104,9 @@ public Optional<ConfigProperty> fetch(final int id) {
public Optional<ConfigProperty> fetch(final String propertyName) {
Objects.requireNonNull(propertyName);
return JooqUtil.contextResult(globalConfigDbConnProvider, context -> context
.selectFrom(CONFIG)
.where(CONFIG.NAME.eq(propertyName))
.fetchOptional())
.selectFrom(CONFIG)
.where(CONFIG.NAME.eq(propertyName))
.fetchOptional())
.map(RECORD_TO_CONFIG_PROPERTY_MAPPER);
}

Expand All @@ -113,15 +121,27 @@ public Optional<Long> getLatestConfigUpdateTimeMs() {

@Override
public ConfigProperty update(final ConfigProperty configProperty) {
return JooqUtil.transactionResultWithOptimisticLocking(
globalConfigDbConnProvider,
context -> {
final ConfigProperty updatedConfigProperty = genericDao.update(
context,
configProperty);
updateTracker(context, updatedConfigProperty);
return updatedConfigProperty;
});
LOGGER.debug(() -> LogUtil.message("Updating config prop {} with id {}, ver {}",
configProperty.getName(), configProperty.getId(), configProperty.getVersion()));
try {
return JooqUtil.transactionResultWithOptimisticLocking(
globalConfigDbConnProvider,
context -> {
final ConfigProperty updatedConfigProperty = genericDao.update(
context,
configProperty);
updateTracker(context, updatedConfigProperty);
return updatedConfigProperty;
});
} catch (RuntimeException e) {
if (e instanceof DataChangedException) {
// Possible someone has made a direct change in the db, naughty, so change the tracker
// such that the props will get refreshed on all nodes
JooqUtil.context(globalConfigDbConnProvider, context ->
updateTracker(context, System.currentTimeMillis()));
}
throw e;
}
}

@Override
Expand Down Expand Up @@ -150,7 +170,7 @@ public boolean delete(final PropertyPath propertyPath) {
@Override
public List<ConfigProperty> list() {
return JooqUtil.contextResult(globalConfigDbConnProvider, context -> context
.fetch(CONFIG))
.fetch(CONFIG))
.map(RECORD_TO_CONFIG_PROPERTY_MAPPER::apply);
}

Expand All @@ -160,19 +180,55 @@ private void updateTracker(final DSLContext context,
updateTracker(context, updateTimeMs);
}

@Override
public void ensureTracker(final long updateTimeMs) {
JooqUtil.context(globalConfigDbConnProvider, context ->
ensureTracker(context, updateTimeMs));

}

public void ensureTracker(final DSLContext context, final long updateTimeMs) {
// Insert the rec only if it doesn't already exist
context.insertInto(CONFIG_UPDATE_TRACKER,
CONFIG_UPDATE_TRACKER.ID,
CONFIG_UPDATE_TRACKER.UPDATE_TIME_MS)
.select(context.select(DSL.inline(TRACKER_ID), DSL.val(updateTimeMs))
.where(DSL.notExists(context.select(CONFIG_UPDATE_TRACKER.ID)
.from(CONFIG_UPDATE_TRACKER)
.where(CONFIG_UPDATE_TRACKER.ID.equal(TRACKER_ID)))))
.execute();
}

/**
* The tracker table means we have a simple way of checking if any of the DB config has changed
* which can include removal of records. ANY mutation of the config table MUST also
* call updateTracker
*/
private void updateTracker(final DSLContext context, final long updateTimeMs) {
context.insertInto(
CONFIG_UPDATE_TRACKER,
CONFIG_UPDATE_TRACKER.ID,
CONFIG_UPDATE_TRACKER.UPDATE_TIME_MS)
.values(TRACKER_ID, updateTimeMs)
.onDuplicateKeyUpdate()
.set(CONFIG_UPDATE_TRACKER.UPDATE_TIME_MS, updateTimeMs)
.execute();
// pkg private for testing
long updateTracker(final DSLContext context, final long updateTimeMs) {
ensureTracker(context, updateTimeMs);

// Lock the row so we can check then update
final Long dbUpdateTimeMs = NullSafe.get(context.select(CONFIG_UPDATE_TRACKER.UPDATE_TIME_MS)
.from(CONFIG_UPDATE_TRACKER)
.where(CONFIG_UPDATE_TRACKER.ID.eq(TRACKER_ID))
.forUpdate()
.fetchOne(),
Record1::value1);

Objects.requireNonNull(dbUpdateTimeMs);

if (dbUpdateTimeMs >= updateTimeMs) {
LOGGER.debug("Config tracker {} is ahead of {}", dbUpdateTimeMs, updateTimeMs);
// Another thread has updated it with a more recent time so just use that
return dbUpdateTimeMs;
} else {
LOGGER.debug("Updated config tracker to {}", updateTimeMs);
context.update(CONFIG_UPDATE_TRACKER)
.set(CONFIG_UPDATE_TRACKER.UPDATE_TIME_MS, updateTimeMs)
.where(CONFIG_UPDATE_TRACKER.ID.eq(TRACKER_ID))
.execute();
return updateTimeMs;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package stroom.config.global.impl.db;

import stroom.test.common.util.db.DbTestModule;
import stroom.util.db.ForceLegacyMigration;

import com.google.inject.AbstractModule;

public class GlobalConfigTestModule extends AbstractModule {

@Override
protected void configure() {
install(new GlobalConfigDaoModule());
install(new GlobalConfigDbModule());
install(new DbTestModule());

bind(ForceLegacyMigration.class).toInstance(new ForceLegacyMigration() {
});
}
}
Loading

0 comments on commit 4ecba66

Please sign in to comment.