Skip to content
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

Fault tolerant execution for SqlServer connector #14730

Merged
merged 2 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ jobs:
- { modules: testing/trino-faulttolerant-tests, profile: test-fault-tolerant-iceberg }
- { modules: testing/trino-faulttolerant-tests, profile: test-fault-tolerant-postgresql }
- { modules: testing/trino-faulttolerant-tests, profile: test-fault-tolerant-mysql }
- { modules: testing/trino-faulttolerant-tests, profile: test-fault-tolerant-sqlserver }
- { modules: testing/trino-tests }
EOF
./.github/bin/build-matrix-from-impacted.py -v -i gib-impacted.log -m .github/test-matrix.yaml -o matrix.json
Expand Down
1 change: 1 addition & 0 deletions docs/src/main/sphinx/admin/fault-tolerant-execution.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ depending on the desired :ref:`retry policy <fte-retry-policy>`.
* :doc:`/connector/iceberg`
* :doc:`/connector/mysql`
* :doc:`/connector/postgresql`
* :doc:`/connector/sqlserver`

The following configuration properties control the behavior of fault-tolerant
execution on a Trino cluster:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public SqlServerClient(
QueryBuilder queryBuilder,
IdentifierMapping identifierMapping)
{
super(config, "\"", connectionFactory, queryBuilder, identifierMapping);
super(config, "\"", connectionFactory, queryBuilder, identifierMapping, true);

this.statisticsEnabled = statisticsConfig.isEnabled();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;

import static io.airlift.testing.Closeables.closeAllSuppress;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
Expand All @@ -46,9 +47,23 @@ public static QueryRunner createSqlServerQueryRunner(
Map<String, String> connectorProperties,
Iterable<TpchTable<?>> tables)
throws Exception
{
return createSqlServerQueryRunner(testingSqlServer, extraProperties, Map.of(), connectorProperties, tables, runner -> {});
}

public static QueryRunner createSqlServerQueryRunner(
TestingSqlServer testingSqlServer,
Map<String, String> extraProperties,
Map<String, String> coordinatorProperties,
Map<String, String> connectorProperties,
Iterable<TpchTable<?>> tables,
Consumer<QueryRunner> moreSetup)
throws Exception
{
DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(createSession(testingSqlServer.getUsername()))
.setExtraProperties(extraProperties)
.setCoordinatorProperties(coordinatorProperties)
.setAdditionalSetup(moreSetup)
.build();
try {
queryRunner.installPlugin(new TpchPlugin());
Expand Down
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,13 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-sqlserver</artifactId>
<type>test-jar</type>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-testing</artifactId>
Expand Down
38 changes: 38 additions & 0 deletions testing/trino-faulttolerant-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,19 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-sqlserver</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-sqlserver</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-testing</artifactId>
Expand Down Expand Up @@ -390,6 +403,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mssqlserver</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
Expand Down Expand Up @@ -452,6 +471,7 @@
<exclude>**/io/trino/faulttolerant/iceberg/Test*.java</exclude>
<exclude>**/io/trino/faulttolerant/mysql/Test*.java</exclude>
<exclude>**/io/trino/faulttolerant/postgresql/Test*.java</exclude>
<exclude>**/io/trino/faulttolerant/sqlserver/Test*.java</exclude>
</excludes>
</configuration>
</plugin>
Expand Down Expand Up @@ -570,5 +590,23 @@
</plugins>
</build>
</profile>

<profile>
<id>test-fault-tolerant-sqlserver</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<threadCount>4</threadCount>
<includes>
<include>**/io/trino/faulttolerant/sqlserver/Test*.java</include>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update excludes section above:

<excludes>
                                <exclude>**/io/trino/faulttolerant/delta/Test*.java</exclude>
                                <exclude>**/io/trino/faulttolerant/hive/Test*.java</exclude>
                                <exclude>**/io/trino/faulttolerant/iceberg/Test*.java</exclude>
                                <exclude>**/io/trino/faulttolerant/mysql/Test*.java</exclude>
                                <exclude>**/io/trino/faulttolerant/postgresql/Test*.java</exclude>
                            </excludes>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.faulttolerant.sqlserver;

import com.google.common.collect.ImmutableMap;
import io.trino.faulttolerant.jdbc.BaseJdbcFailureRecoveryTest;
import io.trino.operator.RetryPolicy;
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.plugin.sqlserver.TestingSqlServer;
import io.trino.testing.QueryRunner;
import io.trino.tpch.TpchTable;

import java.util.List;
import java.util.Map;

import static io.trino.plugin.sqlserver.SqlServerQueryRunner.createSqlServerQueryRunner;

public abstract class BaseSqlServerFailureRecoveryTest
extends BaseJdbcFailureRecoveryTest
{
public BaseSqlServerFailureRecoveryTest(RetryPolicy retryPolicy)
{
super(retryPolicy);
}

@Override
protected QueryRunner createQueryRunner(
List<TpchTable<?>> requiredTpchTables,
Map<String, String> configProperties,
Map<String, String> coordinatorProperties)
throws Exception
{
return createSqlServerQueryRunner(
closeAfterClass(new TestingSqlServer()),
configProperties,
coordinatorProperties,
Map.of(),
requiredTpchTables,
runner -> {
runner.installPlugin(new FileSystemExchangePlugin());
runner.loadExchangeManager("filesystem", ImmutableMap.<String, String>builder()
.put("exchange.base-directories", System.getProperty("java.io.tmpdir") + "/trino-local-file-system-exchange-manager")
.buildOrThrow());
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.faulttolerant.sqlserver;

import io.trino.operator.RetryPolicy;

public class TestSqlServerQueryFailureRecoveryTest
extends BaseSqlServerFailureRecoveryTest
{
public TestSqlServerQueryFailureRecoveryTest()
{
super(RetryPolicy.QUERY);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.faulttolerant.sqlserver;

import io.trino.operator.RetryPolicy;

public class TestSqlServerTaskFailureRecoveryTest
extends BaseSqlServerFailureRecoveryTest
{
public TestSqlServerTaskFailureRecoveryTest()
{
super(RetryPolicy.TASK);
}
}