2

私のコミット間隔が1000であるとしましょう。

書き込み中に、スキップポリシーに従ってスキップ可能な990番目のレコードでエラーが発生します。

したがって、ロールバックが発生し、ライターはレコード 1 から同じレコードの書き込みを再開します。

ただし、今回は、レコードごとにコミットしています。コミット間隔を尊重しません。これにより、ジョブが非常に遅くなります。

なぜそのような行動になるのですか?? 構成に何か不足していますか??

ありがとう。

4

1 に答える 1

3

その動作は、Spring バッチが不良アイテムを分離するために必須です。基本的には、チャンクをロールバックし、各アイテムを commit-rate=1 で処理/書き込みして不良アイテムを見つけます (プロセッサまたはライターのいずれかで)。

同様の問題に対する春のバッチフォーラムのコメントを参照してください

該当部分

--> 5 items read, processing starts
<processor called:15>
<processor called:16>
<processor called:17> will throw an error on write
<processor called:18>
<processor called:19>
<before write:[15, 16, 17, 18, 19]>
<on write error>
--> error on item 17, but it was in the list, lets find it
--> rollback
<before chunk>
--> spring batch goes through all items of the chunk again to find the bad item
--> basically it runs now with commit-rate="1" (only for this chunk)
<processor called:15>
<after write:[15]>
<after chunk>
<before chunk>
<processor called:16>
<after write:[16]>
<after chunk>
<before chunk>
<processor called:17> called again for the bad item, because it's still unknown to spring batch, that this is the bad one
--> no write, because itemWriter.write() was called with the bad item only and did throw an exception (again)
--> but now spring batch knows the bad item
<before chunk>
于 2011-08-11T13:14:23.837 に答える