embulk-output-mysql 0.8.4 → 0.8.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a6b83378d49fc8b2a03de7296e7da18eab89050
|
4
|
+
data.tar.gz: 5e0d6bcb0fd421179ba89b6284883b87d7cd0e45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c84ec4e5a7acaa7173a54e0d339d5b38a70cc17d5692cd4a0452c21f186eb6d71c7476a13cbefeb6e03e0f8a60751a9d91bc87f8251fe9c2ee22a895600b65d
|
7
|
+
data.tar.gz: edf085322564c9f9592bc014889e145b72d2f28ccac8b5734bc062b9f826427b28e9934ca00a5b5b80f7d82cf8daf6c278e27ca578e486f8a50b388d8c5aedba
|
Binary file
|
Binary file
|
@@ -29,6 +29,11 @@ import com.google.common.io.Resources;
|
|
29
29
|
|
30
30
|
public class RetryTest
|
31
31
|
{
|
32
|
+
private static class Lock
|
33
|
+
{
|
34
|
+
public boolean enabled = true;
|
35
|
+
}
|
36
|
+
|
32
37
|
private static final String BASIC_RESOURCE_PATH = "org/embulk/output/mysql/test/expect/retry/";
|
33
38
|
|
34
39
|
private static ConfigSource loadYamlResource(TestingEmbulk embulk, String fileName)
|
@@ -151,7 +156,7 @@ public class RetryTest
|
|
151
156
|
}
|
152
157
|
}
|
153
158
|
|
154
|
-
final
|
159
|
+
final Lock lock = new Lock();
|
155
160
|
|
156
161
|
Thread thread = new Thread() {
|
157
162
|
@Override
|
@@ -164,16 +169,18 @@ public class RetryTest
|
|
164
169
|
for (int i = 1000000; i < 1260000; i++) {
|
165
170
|
statement.execute("insert into test1 values('B" + i + "', 0)");
|
166
171
|
}
|
172
|
+
System.out.println("# Inserted many records.");
|
167
173
|
|
168
174
|
synchronized (lock) {
|
169
175
|
lock.notify();
|
176
|
+
lock.enabled = false;
|
170
177
|
}
|
171
178
|
|
172
|
-
System.out.println("
|
173
|
-
|
179
|
+
System.out.println("# Insert 'A1249000'.");
|
174
180
|
statement.execute("insert into test1 values('A1249010', 0)");
|
175
181
|
Thread.sleep(5000);
|
176
182
|
// deadlock will occur
|
183
|
+
System.out.println("# Insert 'A1249010'.");
|
177
184
|
statement.execute("insert into test1 values('A1249000', 0)");
|
178
185
|
conn.rollback();
|
179
186
|
}
|
@@ -186,7 +193,175 @@ public class RetryTest
|
|
186
193
|
thread.start();
|
187
194
|
|
188
195
|
synchronized (lock) {
|
189
|
-
lock.
|
196
|
+
if (lock.enabled) {
|
197
|
+
lock.wait();
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
//Path in1 = toPath("test1_flushed_multiple_times.csv");
|
202
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test1.yml")), in1);
|
203
|
+
assertThat(selectRecords(embulk, "test1"), is(expected1.toString()));
|
204
|
+
}
|
205
|
+
|
206
|
+
@Test
|
207
|
+
public void testRetry_MultipleTimes() throws Exception
|
208
|
+
{
|
209
|
+
Thread thread1 = new Thread() {
|
210
|
+
@Override
|
211
|
+
public void run() {
|
212
|
+
try {
|
213
|
+
try (Connection conn = MySQLTests.connect()) {
|
214
|
+
conn.setAutoCommit(false);
|
215
|
+
try (Statement statement = conn.createStatement()) {
|
216
|
+
// make the transaction larger so that embulk-output-mysql transaction will be rolled back at a deadlock.
|
217
|
+
for (int i = 100; i < 110; i++) {
|
218
|
+
statement.execute("insert into test1 values('B" + i + "', 0)");
|
219
|
+
}
|
220
|
+
|
221
|
+
statement.execute("insert into test1 values('A003', 0)");
|
222
|
+
Thread.sleep(3000);
|
223
|
+
// deadlock will occur
|
224
|
+
statement.execute("insert into test1 values('A002', 0)");
|
225
|
+
conn.rollback();
|
226
|
+
}
|
227
|
+
}
|
228
|
+
} catch (Exception e) {
|
229
|
+
e.printStackTrace();
|
230
|
+
}
|
231
|
+
}
|
232
|
+
};
|
233
|
+
thread1.start();
|
234
|
+
|
235
|
+
Thread thread2 = new Thread() {
|
236
|
+
@Override
|
237
|
+
public void run() {
|
238
|
+
try {
|
239
|
+
try (Connection conn = MySQLTests.connect()) {
|
240
|
+
conn.setAutoCommit(false);
|
241
|
+
try (Statement statement = conn.createStatement()) {
|
242
|
+
// make the transaction larger so that embulk-output-mysql transaction will be rolled back at a deadlock.
|
243
|
+
for (int i = 100; i < 110; i++) {
|
244
|
+
statement.execute("insert into test1 values('C" + i + "', 0)");
|
245
|
+
}
|
246
|
+
|
247
|
+
statement.execute("insert into test1 values('A004', 0)");
|
248
|
+
Thread.sleep(6000);
|
249
|
+
// deadlock will occur
|
250
|
+
statement.execute("insert into test1 values('A001', 0)");
|
251
|
+
conn.rollback();
|
252
|
+
}
|
253
|
+
}
|
254
|
+
} catch (Exception e) {
|
255
|
+
e.printStackTrace();
|
256
|
+
}
|
257
|
+
}
|
258
|
+
};
|
259
|
+
thread2.start();
|
260
|
+
|
261
|
+
Path in1 = toPath("test1.csv");
|
262
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test1.yml")), in1);
|
263
|
+
assertThat(selectRecords(embulk, "test1"), is(readResource("test1_expected.csv")));
|
264
|
+
}
|
265
|
+
|
266
|
+
// records will be partially committed
|
267
|
+
@Test
|
268
|
+
public void testRetry_Large_MultipleTimes() throws Exception
|
269
|
+
{
|
270
|
+
Path in1 = embulk.createTempFile("csv");
|
271
|
+
StringBuilder expected1 = new StringBuilder();
|
272
|
+
|
273
|
+
try (BufferedWriter writer = new BufferedWriter(new FileWriter(in1.toFile()))) {
|
274
|
+
writer.write("id:string,num:long");
|
275
|
+
writer.newLine();
|
276
|
+
|
277
|
+
for (int i = 1000000; i < 1250000; i++) {
|
278
|
+
writer.write("A" + i + "," + i);
|
279
|
+
writer.newLine();
|
280
|
+
|
281
|
+
expected1.append("A" + i + "," + i + "\n");
|
282
|
+
}
|
283
|
+
}
|
284
|
+
|
285
|
+
final Lock lock1 = new Lock();
|
286
|
+
final Lock lock2 = new Lock();
|
287
|
+
|
288
|
+
Thread thread1 = new Thread() {
|
289
|
+
@Override
|
290
|
+
public void run() {
|
291
|
+
try {
|
292
|
+
try (Connection conn = MySQLTests.connect()) {
|
293
|
+
conn.setAutoCommit(false);
|
294
|
+
try (Statement statement = conn.createStatement()) {
|
295
|
+
// make the transaction larger so that embulk-output-mysql transaction will be rolled back at a deadlock.
|
296
|
+
for (int i = 1000000; i < 1260000; i++) {
|
297
|
+
statement.execute("insert into test1 values('B" + i + "', 0)");
|
298
|
+
}
|
299
|
+
System.out.println("# Inserted many records (1).");
|
300
|
+
|
301
|
+
synchronized (lock1) {
|
302
|
+
lock1.notify();
|
303
|
+
lock1.enabled = false;
|
304
|
+
}
|
305
|
+
|
306
|
+
System.out.println("# Insert 'A1249010'.");
|
307
|
+
statement.execute("insert into test1 values('A1249010', 0)");
|
308
|
+
Thread.sleep(5000);
|
309
|
+
// deadlock will occur
|
310
|
+
System.out.println("# Insert 'A1249000'.");
|
311
|
+
statement.execute("insert into test1 values('A1249000', 0)");
|
312
|
+
conn.rollback();
|
313
|
+
}
|
314
|
+
}
|
315
|
+
} catch (Exception e) {
|
316
|
+
e.printStackTrace();
|
317
|
+
}
|
318
|
+
}
|
319
|
+
};
|
320
|
+
thread1.start();
|
321
|
+
|
322
|
+
Thread thread2 = new Thread() {
|
323
|
+
@Override
|
324
|
+
public void run() {
|
325
|
+
try {
|
326
|
+
try (Connection conn = MySQLTests.connect()) {
|
327
|
+
conn.setAutoCommit(false);
|
328
|
+
try (Statement statement = conn.createStatement()) {
|
329
|
+
// make the transaction larger so that embulk-output-mysql transaction will be rolled back at a deadlock.
|
330
|
+
for (int i = 1000000; i < 1260000; i++) {
|
331
|
+
statement.execute("insert into test1 values('C" + i + "', 0)");
|
332
|
+
}
|
333
|
+
System.out.println("# Inserted many records (2).");
|
334
|
+
|
335
|
+
synchronized (lock2) {
|
336
|
+
lock2.notify();
|
337
|
+
lock2.enabled = false;
|
338
|
+
}
|
339
|
+
|
340
|
+
System.out.println("# Insert 'A1249030'.");
|
341
|
+
statement.execute("insert into test1 values('A1249030', 0)");
|
342
|
+
Thread.sleep(20000);
|
343
|
+
// deadlock will occur
|
344
|
+
System.out.println("# Insert 'A1249020'.");
|
345
|
+
statement.execute("insert into test1 values('A1249020', 0)");
|
346
|
+
conn.rollback();
|
347
|
+
}
|
348
|
+
}
|
349
|
+
} catch (Exception e) {
|
350
|
+
e.printStackTrace();
|
351
|
+
}
|
352
|
+
}
|
353
|
+
};
|
354
|
+
thread2.start();
|
355
|
+
|
356
|
+
synchronized (lock1) {
|
357
|
+
if (lock1.enabled) {
|
358
|
+
lock1.wait();
|
359
|
+
}
|
360
|
+
}
|
361
|
+
synchronized (lock2) {
|
362
|
+
if (lock2.enabled) {
|
363
|
+
lock2.wait();
|
364
|
+
}
|
190
365
|
}
|
191
366
|
|
192
367
|
//Path in1 = toPath("test1_flushed_multiple_times.csv");
|
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.
|
4
|
+
version: 0.8.5
|
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-
|
11
|
+
date: 2019-05-10 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.
|
23
|
-
- classpath/embulk-output-mysql-0.8.
|
22
|
+
- classpath/embulk-output-jdbc-0.8.5.jar
|
23
|
+
- classpath/embulk-output-mysql-0.8.5.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
|