embulk-output-mysql 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 753cd35ceccb305741025c9f2956e2a8bcd43e0f
4
- data.tar.gz: a264b7fe51085f24b4a96bfe3f98defc45f3ba4f
3
+ metadata.gz: 5bd951816256b91bd4c8ea18655cb69cce02d800
4
+ data.tar.gz: 7f85745159a29910334433785030c998318cefad
5
5
  SHA512:
6
- metadata.gz: e3af007fe65e593ab4ec3740a3a399d9c622e6867af811c2774445744ebe0a972eddc7610c692793a81a8b9eab7e086bc444ef796fb1022c1e686a3ff1ad5343
7
- data.tar.gz: 9e59a1bf4698cca86fc4389c66e84b6a4ad17cc778fc4c72fd55f43377120479fc369f2d91e3247867d00b2f62578624abd368dafa34495c432c01a94e1250b6
6
+ metadata.gz: 2defc0817f7e6bf4671131875e51e2c063c1295a4f31b8d1759ba6755888f7a190c448d13e5c1e651f63ba57078fc1b03d73676ffb39a940dcb21878337889b5
7
+ data.tar.gz: 67b7e2158febcbb3d8c766d8726ddf8ec1f89a597ec64aa089c6d0511f58859c203ebf6ad5fc15373ea3c63746c020406e054e49a778c4d2a88d7598cd5f753c
@@ -5,7 +5,9 @@ import static org.embulk.output.mysql.MySQLTests.selectRecords;
5
5
  import static org.hamcrest.Matchers.is;
6
6
  import static org.junit.Assert.assertThat;
7
7
 
8
+ import java.io.BufferedWriter;
8
9
  import java.io.File;
10
+ import java.io.FileWriter;
9
11
  import java.net.URISyntaxException;
10
12
  import java.net.URL;
11
13
  import java.nio.file.FileSystems;
@@ -97,7 +99,7 @@ public class RetryTest
97
99
 
98
100
  // will be flushed multiple times
99
101
  @Test
100
- public void testRetryLarge() throws Exception
102
+ public void testRetry_FlushedMultipleTimes() throws Exception
101
103
  {
102
104
  Thread thread = new Thread() {
103
105
  @Override
@@ -125,9 +127,71 @@ public class RetryTest
125
127
  };
126
128
  thread.start();
127
129
 
128
- Path in1 = toPath("test1_large.csv");
129
- TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test1_large.yml")), in1);
130
- assertThat(selectRecords(embulk, "test1"), is(readResource("test1_large_expected.csv")));
130
+ Path in1 = toPath("test1_flushed_multiple_times.csv");
131
+ TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test1_flushed_multiple_times.yml")), in1);
132
+ assertThat(selectRecords(embulk, "test1"), is(readResource("test1_flushed_multiple_times_expected.csv")));
133
+ }
134
+
135
+ // records will be partially committed
136
+ @Test
137
+ public void testRetry_Large() throws Exception
138
+ {
139
+ Path in1 = embulk.createTempFile("csv");
140
+ StringBuilder expected1 = new StringBuilder();
141
+
142
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter(in1.toFile()))) {
143
+ writer.write("id:string,num:long");
144
+ writer.newLine();
145
+
146
+ for (int i = 1000000; i < 1250000; i++) {
147
+ writer.write("A" + i + "," + i);
148
+ writer.newLine();
149
+
150
+ expected1.append("A" + i + "," + i + "\n");
151
+ }
152
+ }
153
+
154
+ final Object lock = new Object();
155
+
156
+ Thread thread = new Thread() {
157
+ @Override
158
+ public void run() {
159
+ try {
160
+ try (Connection conn = MySQLTests.connect()) {
161
+ conn.setAutoCommit(false);
162
+ try (Statement statement = conn.createStatement()) {
163
+ // make the transaction larger so that embulk-output-mysql transaction will be rolled back at a deadlock.
164
+ for (int i = 1000000; i < 1260000; i++) {
165
+ statement.execute("insert into test1 values('B" + i + "', 0)");
166
+ }
167
+
168
+ synchronized (lock) {
169
+ lock.notify();
170
+ }
171
+
172
+ System.out.println("##1");
173
+
174
+ statement.execute("insert into test1 values('A1249010', 0)");
175
+ Thread.sleep(5000);
176
+ // deadlock will occur
177
+ statement.execute("insert into test1 values('A1249000', 0)");
178
+ conn.rollback();
179
+ }
180
+ }
181
+ } catch (Exception e) {
182
+ e.printStackTrace();
183
+ }
184
+ }
185
+ };
186
+ thread.start();
187
+
188
+ synchronized (lock) {
189
+ lock.wait();
190
+ }
191
+
192
+ //Path in1 = toPath("test1_flushed_multiple_times.csv");
193
+ TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test1.yml")), in1);
194
+ assertThat(selectRecords(embulk, "test1"), is(expected1.toString()));
131
195
  }
132
196
 
133
197
  private Path toPath(String fileName) throws URISyntaxException
@@ -1,7 +1,7 @@
1
1
  drop table if exists test1;
2
2
 
3
3
  create table test1 (
4
- id char(4),
4
+ id char(8),
5
5
  num int,
6
6
  primary key (id)
7
7
  );
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-mysql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-07 00:00:00.000000000 Z
11
+ date: 2019-05-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Inserts or updates records to a table.
14
14
  email:
@@ -19,8 +19,8 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - README.md
21
21
  - build.gradle
22
- - classpath/embulk-output-jdbc-0.8.3.jar
23
- - classpath/embulk-output-mysql-0.8.3.jar
22
+ - classpath/embulk-output-jdbc-0.8.4.jar
23
+ - classpath/embulk-output-mysql-0.8.4.jar
24
24
  - default_jdbc_driver/mysql-connector-java-5.1.44.jar
25
25
  - lib/embulk/output/mysql.rb
26
26
  - src/main/java/org/embulk/output/MySQLOutputPlugin.java
@@ -67,9 +67,9 @@ files:
67
67
  - src/test/resources/org/embulk/output/mysql/test/expect/retry/test1.csv
68
68
  - src/test/resources/org/embulk/output/mysql/test/expect/retry/test1.yml
69
69
  - src/test/resources/org/embulk/output/mysql/test/expect/retry/test1_expected.csv
70
- - src/test/resources/org/embulk/output/mysql/test/expect/retry/test1_large.csv
71
- - src/test/resources/org/embulk/output/mysql/test/expect/retry/test1_large.yml
72
- - src/test/resources/org/embulk/output/mysql/test/expect/retry/test1_large_expected.csv
70
+ - src/test/resources/org/embulk/output/mysql/test/expect/retry/test1_flushed_multiple_times.csv
71
+ - src/test/resources/org/embulk/output/mysql/test/expect/retry/test1_flushed_multiple_times.yml
72
+ - src/test/resources/org/embulk/output/mysql/test/expect/retry/test1_flushed_multiple_times_expected.csv
73
73
  homepage: https://github.com/embulk/embulk-output-jdbc
74
74
  licenses:
75
75
  - Apache 2.0