WillemJiang closed pull request #226: SCB-741 change payloads database type 
from varbinary(10240) to blob
URL: https://github.com/apache/incubator-servicecomb-saga/pull/226
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/alpha/alpha-server/src/main/resources/schema-mysql.sql 
b/alpha/alpha-server/src/main/resources/schema-mysql.sql
index ecb934e3..b1598573 100644
--- a/alpha/alpha-server/src/main/resources/schema-mysql.sql
+++ b/alpha/alpha-server/src/main/resources/schema-mysql.sql
@@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS TxEvent (
   type varchar(50) NOT NULL,
   compensationMethod varchar(256) NOT NULL,
   expiryTime datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
-  payloads varbinary(10240),
+  payloads blob,
   retries int(11) NOT NULL DEFAULT '0',
   retryMethod varchar(256) DEFAULT NULL,
   PRIMARY KEY (surrogateId),
@@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS Command (
   localTxId varchar(36) NOT NULL,
   parentTxId varchar(36) DEFAULT NULL,
   compensationMethod varchar(256) NOT NULL,
-  payloads varbinary(10240),
+  payloads blob,
   status varchar(12),
   lastModified datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
   version bigint NOT NULL,
diff --git a/alpha/alpha-server/src/test/resources/schema.sql 
b/alpha/alpha-server/src/test/resources/schema.sql
index 8d708990..0da26860 100644
--- a/alpha/alpha-server/src/test/resources/schema.sql
+++ b/alpha/alpha-server/src/test/resources/schema.sql
@@ -28,7 +28,7 @@ CREATE TABLE IF NOT EXISTS TxEvent (
   expiryTime TIMESTAMP NOT NULL,
   retryMethod varchar(256) NOT NULL,
   retries int DEFAULT 0 NOT NULL,
-  payloads varbinary(10240)
+  payloads blob
 );
 
 CREATE TABLE IF NOT EXISTS Command (
@@ -40,7 +40,7 @@ CREATE TABLE IF NOT EXISTS Command (
   localTxId varchar(36) NOT NULL,
   parentTxId varchar(36) DEFAULT NULL,
   compensationMethod varchar(256) NOT NULL,
-  payloads varbinary(10240),
+  payloads blob,
   status varchar(12),
   lastModified TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
   version bigint NOT NULL
diff --git 
a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxAbortedEvent.java
 
b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxAbortedEvent.java
index f0bac541..0a4146af 100644
--- 
a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxAbortedEvent.java
+++ 
b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxAbortedEvent.java
@@ -23,6 +23,9 @@
 import org.apache.servicecomb.saga.common.EventType;
 
 public class TxAbortedEvent extends TxEvent {
+
+  private static final int PAYLOADS_MAX_LENGTH = 10240;
+
   public TxAbortedEvent(String globalTxId, String localTxId, String 
parentTxId, String compensationMethod, Throwable throwable) {
     super(EventType.TxAbortedEvent, globalTxId, localTxId, parentTxId, 
compensationMethod, 0, "", 0,
         stackTrace(throwable));
@@ -31,6 +34,10 @@ public TxAbortedEvent(String globalTxId, String localTxId, 
String parentTxId, St
   private static String stackTrace(Throwable e) {
     StringWriter writer = new StringWriter();
     e.printStackTrace(new PrintWriter(writer));
-    return writer.toString();
+    String stackTrace = writer.toString();
+    if (stackTrace.length() > PAYLOADS_MAX_LENGTH) {
+      stackTrace = stackTrace.substring(0, PAYLOADS_MAX_LENGTH);
+    }
+    return stackTrace;
   }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to