Revision 21d0f6c7

b/doc/design-2.3.rst
154 154
Current state and shortcomings
155 155
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
156 156

  
157
.. TODO: Describe current situation
157
Currently all jobs and opcodes have the same priority. Once a job
158
started executing, its thread won't be released until all opcodes got
159
their locks and did their work. When a job is finished, the next job is
160
selected strictly by its incoming order. This does not mean jobs are run
161
in their incoming order—locks and other delays can cause them to be
162
stalled for some time.
163

  
164
In some situations, e.g. an emergency shutdown, one may want to run a
165
job as soon as possible. This is not possible currently if there are
166
pending jobs in the queue.
158 167

  
159 168
Proposed changes
160 169
~~~~~~~~~~~~~~~~
161 170

  
162
.. TODO: Describe changes to job queue and potentially client programs
171
Each opcode will be assigned a priority on submission. Opcode priorities
172
are integers and the lower the number, the higher the opcode's priority
173
is. Within the same priority, jobs and opcodes are initially processed
174
in their incoming order.
175

  
176
Submitted opcodes can have one of the priorities listed below. Other
177
priorities are reserved for internal use. The absolute range is
178
-20..+19. Opcodes submitted without a priority (e.g. by older clients)
179
are assigned the default priority.
180

  
181
  - High (-10)
182
  - Normal (0, default)
183
  - Low (+10)
184

  
185
As a change from the current model where executing a job blocks one
186
thread for the whole duration, the new job processor must return the job
187
to the queue after each opcode and also if it can't get all locks in a
188
reasonable timeframe. This will allow opcodes of higher priority
189
submitted in the meantime to be processed or opcodes of the same
190
priority to try to get their locks. When added to the job queue's
191
workerpool, the priority is determined by the first unprocessed opcode
192
in the job.
193

  
194
If an opcode is deferred, the job will go back to the "queued" status,
195
even though it's just waiting to try to acquire its locks again later.
196

  
197
If an opcode can not be processed after a certain number of retries or a
198
certain amount of time, it should increase its priority. This will avoid
199
starvation.
200

  
201
A job's priority can never go below -20. If a job hits priority -20, it
202
must acquire its locks in blocking mode.
203

  
204
Opcode priorities are synchronized to disk in order to be restored after
205
a restart or crash of the master daemon.
206

  
207
Priorities also need to be considered inside the locking library to
208
ensure opcodes with higher priorities get locks first, but the design
209
changes for this will be discussed in a separate section.
163 210

  
164 211
Worker pool
165 212
+++++++++++

Also available in: Unified diff