Skip to content

Commit

Permalink
Fault tolerant execution for SqlServer
Browse files Browse the repository at this point in the history
  • Loading branch information
mwd410 committed Oct 25, 2022
1 parent a2bb3ed commit e625b93
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 1 deletion.
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
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>
</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);
}
}

0 comments on commit e625b93

Please sign in to comment.