Skip to content

Commit d455fda

Browse files
committed
add comments
1 parent 46e2180 commit d455fda

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

Diff for: common/persistence/nosql/nosqlplugin/interfaces.go

+19-13
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ type (
9999
* Recommendation: use two tables(queue_message,and queue_metadata) to implement this interface
100100
* Significant columns:
101101
* 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)
103103
*/
104104
messageQueueCRUD interface {
105105
//Insert message into queue, return error if failed or already exists
@@ -133,15 +133,17 @@ type (
133133
/***
134134
* domainCRUD is for domain + domain metadata storage system
135135
*
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
137137
* Significant columns:
138138
* 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)
139140
*
140141
* Note 1: About Cassandra's implementation: Because of historical reasons, Cassandra uses two table,
141142
* domains and domains_by_name_v2. Therefore, Cassandra implementation lost the atomicity causing some edge cases,
142143
* and the implementation is more complicated than it should be.
143144
*
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.
145147
* The main purpose of it is to notify clusters that there is some changes in domains, so domain cache needs to refresh.
146148
* It always increase by one, whenever a domain is updated or inserted.
147149
* Updating this failover metadata with domain insert/update needs to be atomic.
@@ -166,16 +168,20 @@ type (
166168
SelectDomainMetadata(ctx context.Context) (int64, error)
167169
}
168170

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+
*/
179185
shardCRUD interface {
180186
// InsertShard creates a new shard.
181187
// Return error is there is any thing wrong

0 commit comments

Comments
 (0)