@@ -183,6 +183,8 @@ type txnWriteBuffer struct {
183
183
// `flushed` tracks whether the buffer has been previously flushed.
184
184
flushed bool
185
185
186
+ pipelineEnabler pipelineEnabler
187
+
186
188
// flushOnNextBatch, if set, indicates that write buffering has just been
187
189
// disabled, and the interceptor should flush any buffered writes when it
188
190
// sees the next BatchRequest.
@@ -215,6 +217,14 @@ type txnWriteBuffer struct {
215
217
testingOverrideCPutEvalFn func (expBytes []byte , actVal * roachpb.Value , actValPresent bool , allowNoExisting bool ) * kvpb.ConditionFailedError
216
218
}
217
219
220
+ type pipelineEnabler interface {
221
+ enableImplicitPipelining ()
222
+ }
223
+
224
+ func (twb * txnWriteBuffer ) init (pe pipelineEnabler ) {
225
+ twb .pipelineEnabler = pe
226
+ }
227
+
218
228
func (twb * txnWriteBuffer ) setEnabled (enabled bool ) {
219
229
if ! enabled && twb .buffer .Len () > 0 {
220
230
// When disabling write buffering, if we evaluated any requests, we need
@@ -1678,7 +1688,14 @@ func (twb *txnWriteBuffer) flushBufferAndSendBatch(
1678
1688
// Once we've flushed the buffer, we disable write buffering going forward. We
1679
1689
// do this even if the buffer is empty since once we've called this function,
1680
1690
// our buffer no longer represents all of the writes in the transaction.
1681
- log .VEventf (ctx , 2 , "disabling write buffering for this epoch" )
1691
+ log .VEventf (ctx , 2 , "disabling write buffering" )
1692
+ if twb .pipelineEnabler != nil {
1693
+ // We enable pipelining, but only after this request returns.
1694
+ //
1695
+ // TODO(ssd): Consider enabling pipelining for this batch as well once we
1696
+ // have more discipline around the invariants of the batches we are sending.
1697
+ defer twb .pipelineEnabler .enableImplicitPipelining ()
1698
+ }
1682
1699
twb .flushed = true
1683
1700
1684
1701
numKeysBuffered := twb .buffer .Len ()
0 commit comments