-
-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add latest MariaDB v10.6+ (incl. support for OpenSSL 3) #699
Comments
@cverges-medallia thanks for your interest in this project! An upgrade is certainly possible, but I would need a volunteer contributor (you?) to do the actual work to raise a PR... https://github.com/vorburger/MariaDB4j#mariadb-database-jars-and-version-upgrades actually describes how to! FYI multi platform support has historically been a PITA. I'll shortly be adding Windows coverage in CI (watch #649), and macOS M1 is a PITA (see #497 and #628). If you want to contrib to the project and raise PR, I would be happy to review and merge it if OK. PS: If you use MariaDB4j professionally, please consider to, either: to support future maintenance! |
Are there any instructions that the prior contributors used to allow for reproduction of the binaries that are included in |
Did you notice that there are the "old" (initial, original) binary ones, and the "newer scripted from source" ones. Ignore the former, and look only at the latter, e.g. this one . Does that help? PS: A first PR with README doc update to clarify this would be great! |
Unless we attempt to compile MariaDB statically (which I've been trying to do but seems VERY difficult given the cmake build system), it isn't worth trying to fix generically given how problematic Mac and all the MariaDB dependencies are. I've opted to just provide my own autoconfig classes with mechanisms for detecting Mac and Homebrew paths appropriately whilst simultaneously still allowing for Linux and Windows support to be transparent. Making it super generic isn't ideal for me at the moment given priorities, but maybe this can help provide someone else a guide: import java.io.File;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
import javax.sql.DataSource;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOCase;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import ch.vorburger.mariadb4j.DBConfiguration;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
@Configuration
public class HomebrewAwareMariaDb4jAutoconfig {
@Bean("mariadbHomebrewBasePath")
public String mariadbHomebrewBasePath(
@Value("${mariadb4j.homebrew.basePath:/usr/local/opt}") final String homebrewBasePath,
@Value("${mariadb4j.homebrew.mariadbBasePath:}") final String mariadbBasePathFromConfig
) {
if (!SystemUtils.IS_OS_MAC) {
LOGGER.debug("Not running on a Mac, Homebrew not found/supported");
return "";
}
if (StringUtils.isNotBlank(mariadbBasePathFromConfig)) {
// Who are we to argue?
LOGGER.debug("Using {} for MariaDB", mariadbBasePathFromConfig);
return mariadbBasePathFromConfig;
}
// Search the standard homebrew path for all MariaDB4j installations
LOGGER.debug("Finding Homebrew path for MariaDB");
final File homebrewBase = Paths.get(homebrewBasePath).toFile();
if (!homebrewBase.exists()) {
throw new IllegalStateException(
"Cannot find Homebrew installation on your Mac system, please install and try again"
);
}
final List<String> homebrewBaseFileList = FileUtils
.listFilesAndDirs(
homebrewBase,
new WildcardFileFilter("mariadb*", IOCase.SYSTEM),
new WildcardFileFilter("mariadb*", IOCase.SYSTEM)
)
.stream()
.map(f -> f.getPath())
.filter(f -> f.contains("mariadb"))
.collect(Collectors.toList());
if (homebrewBaseFileList.isEmpty()) {
throw new IllegalStateException(
"Cannot find MariaDB installation from Homebrew, "
+ "please install with `brew install mariadb` or similar and try again"
);
}
if (homebrewBaseFileList.size() > 1) {
LOGGER.debug("Found more MariaDB candidates than expected: {}", homebrewBaseFileList);
throw new IllegalStateException(
"Found multiple MariaDB installations from Homebrew, "
+ "please specify one using the `homebrew.basePath` property"
);
}
final String mariadbBasePath = homebrewBaseFileList.get(0);
LOGGER.debug("Using MariaDB installation from {}", mariadbBasePath);
return mariadbBasePath;
}
@Bean
@Primary
public MariaDB4jSpringService mariaDB4j(
@Qualifier("mariadbHomebrewBasePath") String mariadbHomebrewBasePath
) {
LOGGER.debug("Creating MariaDB4j service");
final MariaDB4jSpringService service = new MariaDB4jSpringService();
if (StringUtils.isNotBlank(mariadbHomebrewBasePath)) {
// Do whatever customization is desired here
// service.setDefaultPort(3307);
service.setDefaultIsUnpackingFromClasspath(false);
service.setDefaultLibDir(SystemUtils.JAVA_IO_TMPDIR + "/MariaDB4j/no-libs");
service.setDefaultBaseDir(mariadbHomebrewBasePath);
}
return service;
}
@Bean
@Primary
public DataSource dataSource(
final MariaDB4jSpringService mariaDB4jSpringService,
final DataSourceProperties dataSourceProperties,
@Value("${mariadb4j.databaseName}") final String databaseName
) throws ManagedProcessException {
LOGGER.debug("Creating datasource for MariaDB4j");
// Create an initial database with default user
mariaDB4jSpringService.getDB().createDB(databaseName);
return DataSourceBuilder.create()
.driverClassName(dataSourceProperties.getDriverClassName())
.url(dataSourceProperties.getUrl())
.username(dataSourceProperties.getUsername())
.password(dataSourceProperties.getPassword())
.build();
}
} As a concept for the future, it might be interesting to allow for Bean injection of a MariaDB4jNativeExecutableDetectionStrategy (@ConditionOnMissingBean some default implementation) so that fully copying the Spring configuration implementation isn't required and the app can just inject their own to override this behavior. |
@cverges-medallia in #771 @TheKnowles has contributed (and it got merged as part of #772) a newer version MariaDB binaries. I'm closing this issue, as what its title originally suggested is done with that PR. Re. re-building binaries with static linking for Mac, please engage on #497. |
If you need this for integration tests, do yourself a favor and switch to TestContainers. Our long nightmare is over at last:
|
MariaDB4j 3.1 version matches openSSL1.1 or openSSL3 ? |
OpenSSL 3.x is now out, but MariaDB4j seems to still be using versions that rely on libssl.1.0.0. (#278 for example.) Downgrading to OpenSSL 1.0 on newer OS installations causes other system problems that make such a workaround infeasible.
Newer versions of MariaDB (10.6+) appear to have OpenSSL 3.x support (https://jira.mariadb.org/browse/MDEV-25785). If possible, can the base version of MariaDB provided for by MariaDB4j be upgraded?
The text was updated successfully, but these errors were encountered: