99
99
* Recommendation: use two tables(queue_message,and queue_metadata) to implement this interface
100
100
* Significant columns:
101
101
* queue_message partition key: (queueType), range key: (messageID)
102
- * queue_metadata partition key: (queueType), range key: N/A
102
+ * queue_metadata partition key: (queueType), range key: N/A, query condition column(version)
103
103
*/
104
104
messageQueueCRUD interface {
105
105
//Insert message into queue, return error if failed or already exists
@@ -133,15 +133,17 @@ type (
133
133
/***
134
134
* domainCRUD is for domain + domain metadata storage system
135
135
*
136
- * Recommendation: Use one table to implement
136
+ * Recommendation: Use two tables(domain, domain_metadata) to implement if conditional updates on two tables is supported
137
137
* Significant columns:
138
138
* domain: partition key( a constant value), range key(domainName), local secondary index(domainID)
139
+ * domain_metadata: partition key( a constant value), range key(a constant value), query condition column(notificationVersion)
139
140
*
140
141
* Note 1: About Cassandra's implementation: Because of historical reasons, Cassandra uses two table,
141
142
* domains and domains_by_name_v2. Therefore, Cassandra implementation lost the atomicity causing some edge cases,
142
143
* and the implementation is more complicated than it should be.
143
144
*
144
- * Note 2: About the special record as "domain metadata". Right now it is an integer number as notification version.
145
+ * Note 2: Cassandra doesn't support conditional updates on multiple tables. Hence the domain_metadata table is implemented
146
+ * as a special record as "domain metadata". It is an integer number as notification version.
145
147
* The main purpose of it is to notify clusters that there is some changes in domains, so domain cache needs to refresh.
146
148
* It always increase by one, whenever a domain is updated or inserted.
147
149
* Updating this failover metadata with domain insert/update needs to be atomic.
@@ -166,16 +168,20 @@ type (
166
168
SelectDomainMetadata (ctx context.Context ) (int64 , error )
167
169
}
168
170
169
- // shardCRUD is for shard storage of workflow execution.
170
- //
171
- // Recommendation: use one table if database support batch conditional update on multiple tables, otherwise combine with workflowCRUD (likeCassandra)
172
- // shard: partition key(shardID), range key(N/A)
173
- //
174
- // Note 1: shard will be required to run conditional update with workflowCRUD. So in some nosql database like Cassandra,
175
- // shardCRUD and workflowCRUD must be implemented within the same table. Because Cassandra only allows LightWeight transaction
176
- // executed within a single table.
177
- // Note 2: unlike Cassandra, most NoSQL databases don't return the previous rows when conditional write fails. In this case,
178
- // an extra read query is needed to get the previous row.
171
+ /**
172
+ * shardCRUD is for shard storage of workflow execution.
173
+
174
+ * Recommendation: use one table if database support batch conditional update on multiple tables, otherwise combine with workflowCRUD (likeCassandra)
175
+ *
176
+ * Significant columns:
177
+ * domain: partition key(shardID), range key(N/A), local secondary index(domainID), query condition column(rangeID)
178
+ *
179
+ * Note 1: shard will be required to run conditional update with workflowCRUD. So in some nosql database like Cassandra,
180
+ * shardCRUD and workflowCRUD must be implemented within the same table. Because Cassandra only allows LightWeight transaction
181
+ * executed within a single table.
182
+ * Note 2: unlike Cassandra, most NoSQL databases don't return the previous rows when conditional write fails. In this case,
183
+ * an extra read query is needed to get the previous row.
184
+ */
179
185
shardCRUD interface {
180
186
// InsertShard creates a new shard.
181
187
// Return error is there is any thing wrong
0 commit comments