@@ -711,8 +711,10 @@ pgaio_io_wait_for_free(void)
711
711
{
712
712
int reclaimed = 0 ;
713
713
714
- pgaio_debug (DEBUG2 , "waiting for self with %d pending" ,
715
- pgaio_my_backend -> num_staged_ios );
714
+ pgaio_debug (DEBUG2 , "waiting for free IO with %d pending, %d in-flight, %d idle IOs" ,
715
+ pgaio_my_backend -> num_staged_ios ,
716
+ dclist_count (& pgaio_my_backend -> in_flight_ios ),
717
+ dclist_is_empty (& pgaio_my_backend -> idle_ios ));
716
718
717
719
/*
718
720
* First check if any of our IOs actually have completed - when using
@@ -743,7 +745,12 @@ pgaio_io_wait_for_free(void)
743
745
pgaio_submit_staged ();
744
746
745
747
if (dclist_count (& pgaio_my_backend -> in_flight_ios ) == 0 )
746
- elog (ERROR , "no free IOs despite no in-flight IOs" );
748
+ ereport (ERROR ,
749
+ errmsg_internal ("no free IOs despite no in-flight IOs" ),
750
+ errdetail_internal ("%d pending, %d in-flight, %d idle IOs" ,
751
+ pgaio_my_backend -> num_staged_ios ,
752
+ dclist_count (& pgaio_my_backend -> in_flight_ios ),
753
+ dclist_is_empty (& pgaio_my_backend -> idle_ios )));
747
754
748
755
/*
749
756
* Wait for the oldest in-flight IO to complete.
@@ -1136,7 +1143,13 @@ pgaio_closing_fd(int fd)
1136
1143
* For now just submit all staged IOs - we could be more selective, but
1137
1144
* it's probably not worth it.
1138
1145
*/
1139
- pgaio_submit_staged ();
1146
+ if (pgaio_my_backend -> num_staged_ios > 0 )
1147
+ {
1148
+ pgaio_debug (DEBUG2 ,
1149
+ "submitting %d IOs before FD %d gets closed" ,
1150
+ pgaio_my_backend -> num_staged_ios , fd );
1151
+ pgaio_submit_staged ();
1152
+ }
1140
1153
1141
1154
/*
1142
1155
* If requested by the IO method, wait for all IOs that use the
@@ -1168,6 +1181,10 @@ pgaio_closing_fd(int fd)
1168
1181
if (!ioh )
1169
1182
break ;
1170
1183
1184
+ pgaio_debug_io (DEBUG2 , ioh ,
1185
+ "waiting for IO before FD %d gets closed, %d in-flight IOs" ,
1186
+ fd , dclist_count (& pgaio_my_backend -> in_flight_ios ));
1187
+
1171
1188
/* see comment in pgaio_io_wait_for_free() about raciness */
1172
1189
pgaio_io_wait (ioh , ioh -> generation );
1173
1190
}
@@ -1199,6 +1216,10 @@ pgaio_shutdown(int code, Datum arg)
1199
1216
{
1200
1217
PgAioHandle * ioh = dclist_head_element (PgAioHandle , node , & pgaio_my_backend -> in_flight_ios );
1201
1218
1219
+ pgaio_debug_io (DEBUG2 , ioh ,
1220
+ "waiting for IO to complete during shutdown, %d in-flight IOs" ,
1221
+ dclist_count (& pgaio_my_backend -> in_flight_ios ));
1222
+
1202
1223
/* see comment in pgaio_io_wait_for_free() about raciness */
1203
1224
pgaio_io_wait (ioh , ioh -> generation );
1204
1225
}
0 commit comments