@@ -732,6 +732,7 @@ struct session : enable_shared_from_this<session> {
732
732
, create_schema(create_schema) {
733
733
734
734
stream.binary (true );
735
+ stream.read_message_max (1024 * 1024 * 1024 );
735
736
if (drop_schema) {
736
737
pqxx::work t (sql_connection);
737
738
t.exec (" drop schema if exists " + t.quote_name (this ->schema ) + " cascade" );
@@ -969,7 +970,13 @@ struct session : enable_shared_from_this<session> {
969
970
if (!result.this_block )
970
971
return true ;
971
972
972
- bool bulk = result.this_block ->block_num + 4 < result.last_irreversible .block_num ;
973
+ bool bulk = result.this_block ->block_num + 4 < result.last_irreversible .block_num ;
974
+ bool large_deltas = false ;
975
+ if (!bulk && result.deltas && result.deltas ->end - result.deltas ->pos >= 10 * 1024 * 1024 ) {
976
+ cerr << " large deltas size: " << (result.deltas ->end - result.deltas ->pos ) << " \n " ;
977
+ bulk = true ;
978
+ large_deltas = true ;
979
+ }
973
980
974
981
if (stop_before && result.this_block ->block_num >= stop_before) {
975
982
close_streams ();
@@ -984,7 +991,7 @@ struct session : enable_shared_from_this<session> {
984
991
bulk = false ;
985
992
}
986
993
987
- if (!bulk || !(result.this_block ->block_num % 200 ))
994
+ if (!bulk || large_deltas || !(result.this_block ->block_num % 200 ))
988
995
close_streams ();
989
996
if (!bulk) {
990
997
auto n = std::chrono::system_clock::to_time_t (std::chrono::system_clock::now ());
@@ -1016,6 +1023,8 @@ struct session : enable_shared_from_this<session> {
1016
1023
1017
1024
pipeline.complete ();
1018
1025
t.commit ();
1026
+ if (large_deltas)
1027
+ close_streams ();
1019
1028
return true ;
1020
1029
} // receive_result()
1021
1030
@@ -1161,13 +1170,17 @@ struct session : enable_shared_from_this<session> {
1161
1170
throw std::runtime_error (" don't know how to proccess " + variant_type.name );
1162
1171
auto & type = *variant_type.fields [0 ].type ;
1163
1172
1173
+ size_t num_processed = 0 ;
1164
1174
for (auto & row : table_delta.rows ) {
1175
+ if (table_delta.rows .size () > 1000 && !(num_processed % 10000 ))
1176
+ cerr << table_delta.name << " row " << num_processed << " of " << table_delta.rows .size () << " bulk=" << bulk << " \n " ;
1165
1177
check_variant (row.data , variant_type, 0u );
1166
1178
string fields = " block_index, present" ;
1167
1179
string values = to_string (block_num) + sep (bulk) + sql_str (bulk, row.present );
1168
1180
for (auto & field : type.fields )
1169
1181
fill_value (bulk, false , t, " " , fields, values, row.data , field);
1170
1182
write (block_num, t, pipeline, bulk, table_delta.name , fields, values);
1183
+ ++num_processed;
1171
1184
}
1172
1185
numRows += table_delta.rows .size ();
1173
1186
}
@@ -1377,6 +1390,7 @@ int main(int argc, char** argv) {
1377
1390
ioc, vm[" host" ].as <string>(), vm[" port" ].as <string>(), vm[" schema" ].as <string>(),
1378
1391
vm.count (" skip-to" ) ? vm[" skip-to" ].as <uint32_t >() : 0 , vm.count (" stop" ) ? vm[" stop" ].as <uint32_t >() : 0 , vm.count (" drop" ),
1379
1392
vm.count (" create" ));
1393
+ cerr.imbue (std::locale (" " ));
1380
1394
s->start ();
1381
1395
ioc.run ();
1382
1396
}
0 commit comments