@@ -282,19 +282,18 @@ class ContinuousExecution(
282282 epoch : Long , reader : ContinuousReader , partitionOffsets : Seq [PartitionOffset ]): Unit = {
283283 assert(continuousSources.length == 1 , " only one continuous source supported currently" )
284284
285- val globalOffset = reader.mergeOffsets(partitionOffsets.toArray)
286- val oldOffset = synchronized {
287- offsetLog.add(epoch, OffsetSeq .fill(globalOffset))
288- offsetLog.get(epoch - 1 )
289- }
290-
291- // If offset hasn't changed since last epoch, there's been no new data.
292- if (oldOffset.contains(OffsetSeq .fill(globalOffset))) {
293- noNewData = true
294- }
295-
296285 awaitProgressLock.lock()
297286 try {
287+ val globalOffset = reader.mergeOffsets(partitionOffsets.toArray)
288+ val oldOffset = synchronized {
289+ offsetLog.add(epoch, OffsetSeq .fill(globalOffset))
290+ offsetLog.get(epoch - 1 )
291+ }
292+
293+ // If offset hasn't changed since last epoch, there's been no new data.
294+ if (oldOffset.contains(OffsetSeq .fill(globalOffset))) {
295+ noNewData = true
296+ }
298297 awaitProgressLockCondition.signalAll()
299298 } finally {
300299 awaitProgressLock.unlock()
@@ -308,23 +307,22 @@ class ContinuousExecution(
308307 def commit (epoch : Long ): Unit = {
309308 assert(continuousSources.length == 1 , " only one continuous source supported currently" )
310309 assert(offsetLog.get(epoch).isDefined, s " offset for epoch $epoch not reported before commit " )
311- synchronized {
310+
311+ awaitProgressLock.lock()
312+ try {
312313 if (queryExecutionThread.isAlive) {
313314 commitLog.add(epoch)
314315 val offset = offsetLog.get(epoch).get.offsets(0 ).get
315316 committedOffsets ++= Seq (continuousSources(0 ) -> offset)
316317 } else {
317318 return
318319 }
319- }
320320
321- if (minLogEntriesToMaintain < currentBatchId) {
322- offsetLog.purge(currentBatchId - minLogEntriesToMaintain)
323- commitLog.purge(currentBatchId - minLogEntriesToMaintain)
324- }
321+ if (minLogEntriesToMaintain < currentBatchId) {
322+ offsetLog.purge(currentBatchId - minLogEntriesToMaintain)
323+ commitLog.purge(currentBatchId - minLogEntriesToMaintain)
324+ }
325325
326- awaitProgressLock.lock()
327- try {
328326 awaitProgressLockCondition.signalAll()
329327 } finally {
330328 awaitProgressLock.unlock()
0 commit comments