Alright I fixed it, it was stupid. But actually it didn't solve anything...
Here's how I did it :
doJDBCStuff() :
val cpManager = conn.unwrap(classOf[PGConnection]).getCopyAPI
val stringBytes: Array[Byte] = batchStrings.toString().map(_.toByte).toArray
val copy = cpManager.copyIn(s"COPY tableName FROM STDIN WITH CSV")
try {
copy.writeToCopy(stringBytes, 0, stringBytes.length)
copy.endCopy()
} finally {
if(copy.isActive){
copy.cancelCopy()
}
}
conn.commit()
The potential exception should be caught higher in the first snippet I
showed (to resend the message). By the way, I noticed that If I turn on
autoCommit, absolutely all processors are blocking...
Le jeudi 7 août 2014 12:02:48 UTC+2, Brett Wooldridge a écrit :
>
> That error indicates that one of your "us-ascii" files has a NUL byte
> (0x00) in it somewhere, this is never valid in UTF-8. You have two
> options. Figure out why there is a NUL character the file, or at least
> sanitizing the bytes on-the-fly as you read chunks from the file. Either
> redacting the NUL bytes completely, or replacing them with, for example, a
> space (0x20).
>
>
> On Thursday, August 7, 2014 6:10:30 PM UTC+9, Jasper wrote:
>>
>> I tried it and this looks very promising as since all processors now go
>> into Open state. However without the reader I'm deep into encoding hell
>> because my files are in us-ascii and my db in UTF-8 :
>>
>> invalid byte sequence for encoding "UTF8": 0x00
>> And I can't just sanitize the files beforehand... Anyway I'm aware it's
>> not really the place for this so unless anyone have the solution, thanks
>> for your help !
>>
>>
>> Le jeudi 7 août 2014 07:27:04 UTC+2, Brett Wooldridge a écrit :
>>>
>>> It appears that you are using the PostgreSQL CopyManager, correct?
>>> Looking at QueryExecutorImpl it appears that rollback() is trying to
>>> obtain a lock that was not released by the CopyManager. I recommend using
>>> the CopyManager.copyIn() method that returns a CopyIn object, rather
>>> than using the convenience method that takes a reader. Use the
>>> writeToCopy() to pump the data in, and be sure to catch SQLException.
>>> If you get an SQLException, call cancelCopy() and retry or whatever
>>> your recovery scenario is, otherwise call endCopy(). I would have
>>> expected PostgreSQL to handle the severing of a Connection in the middle of
>>> a bulk copy better, but that is probably a question for the PostgreSQL
>>> group.
>>>
>>> Just my armchair diagnosis.
>>>
>>> On Wednesday, August 6, 2014 11:04:13 PM UTC+9, Jasper wrote:
>>>>
>>>>
>>>> Sys-akka.actor.pinned-dispatcher-6 [WAITING]
>>>> java.lang.Object.wait()Object.java:503
>>>> org.postgresql.core.v3.QueryExecutorImpl.waitOnLock()QueryExecutorImpl.
>>>> java:91
>>>> org.postgresql.core.v3.QueryExecutorImpl.execute(Query, ParameterList,
>>>> ResultHandler, int, int, int)QueryExecutorImpl.java:228
>>>> org.postgresql.jdbc2.AbstractJdbc2Connection.executeTransactionCommand(
>>>> Query)AbstractJdbc2Connection.java:808
>>>> org.postgresql.jdbc2.AbstractJdbc2Connection.rollback()
>>>> AbstractJdbc2Connection.java:861
>>>> com.zaxxer.hikari.proxy.ConnectionProxy.resetConnectionState()
>>>> ConnectionProxy.java:192
>>>> com.zaxxer.hikari.proxy.ConnectionProxy.close()ConnectionProxy.java:305
>>>> java.lang.reflect.Method.invoke(Object, Object[])Method.java:606
>>>> xx.xxxx.util.Cleaning$.using(Object, Function1)Cleaning.scala:14
>>>> xx.xxxx.actors.FileProcessor$$anonfun$receive$1$$anonfun$applyOrElse$1.
>>>> apply$mcV$sp()FileProcessor.scala:75
>>>> xx.xxxx.actors.FileProcessor$$anonfun$receive$1$$anonfun$applyOrElse$1.
>>>> apply()FileProcessor.scala:56
>>>> xx.xxxx.actors.FileProcessor$$anonfun$receive$1$$anonfun$applyOrElse$1.
>>>> apply()FileProcessor.scala:56
>>>> akka.pattern.CircuitBreaker$$anonfun$withSyncCircuitBreaker$1.apply()
>>>> CircuitBreaker.scala:135
>>>> akka.pattern.CircuitBreaker$$anonfun$withSyncCircuitBreaker$1.apply()
>>>> CircuitBreaker.scala:135
>>>> akka.pattern.CircuitBreaker$State$class.callThrough(
>>>> CircuitBreaker$State, Function0)CircuitBreaker.scala:296
>>>> akka.pattern.CircuitBreaker$Closed$.callThrough(Function0)
>>>> CircuitBreaker.scala:345
>>>> akka.pattern.CircuitBreaker$Closed$.invoke(Function0)CircuitBreaker.
>>>> scala:354
>>>> akka.pattern.CircuitBreaker.withCircuitBreaker(Function0)CircuitBreaker
>>>> .scala:113
>>>> akka.pattern.CircuitBreaker.withSyncCircuitBreaker(Function0)
>>>> CircuitBreaker.scala:135
>>>> xx.xxxx.actors.FileProcessor$$anonfun$receive$1.applyOrElse(Object,
>>>> Function1)FileProcessor.scala:55
>>>> akka.actor.Actor$class.aroundReceive(Actor, PartialFunction, Object)
>>>> Actor.scala:</spa
>>>> ...
>>>
>>>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.