Why do I see ttyUSB2 on nmcli, not see wwan0? - modem

I want to use NetworkManager to control wwan0. But I only see ttyUSB2 in NetworkManager device list.
I use "cat" command to make ttyUSB2 & ttyUSB3 in use, but it doesn't work.
The below is modemmanager info
root#imx6qsabresd:~# mmcli -m 0
/org/freedesktop/ModemManager1/Modem/0 (device id '74d82342f71de5945dddcc381409e231f5ed5df1')
-------------------------
Hardware | manufacturer: 'SIMCOM INCORPORATED'
| model: 'SIMCOM_SIM7600JC-H'
| revision: 'LE11B01SIM7600JC-H'
| supported: 'gsm-umts, lte'
| current: 'gsm-umts, lte'
| equipment id: '861478030131862'
-------------------------
System | device: '/sys/devices/soc0/soc/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb1/1-1/1-1.1'
| drivers: 'option1, simcom_wwan'
| plugin: 'SimTech'
| primary port: 'ttyUSB2'
| ports: 'ttyUSB0 (qcdm), ttyUSB2 (at), ttyUSB3 (at), wwan0 (net)'
-------------------------
Numbers | own : 'unknown'
-------------------------
Status | lock: 'none'
| unlock retries: 'unknown'
| state: 'registered'
| power state: 'on'
| access tech: 'unknown'
| signal quality: '80' (recent)
-------------------------
Modes | supported: 'allowed: 2g; preferred: none
| allowed: 3g; preferred: none
| allowed: 2g, 3g; preferred: none
| allowed: 2g, 3g; preferred: 2g
| allowed: 2g, 3g; preferred: 3g
| allowed: 2g, 3g, 4g; preferred: none'
| current: 'allowed: any; preferred: none'
-------------------------
Bands | supported: 'unknown'
| current: 'unknown'
-------------------------
IP | supported: 'ipv4, ipv6, ipv4v6'
-------------------------
3GPP | imei: '861478030131862'
| enabled locks: 'none'
| operator id: '46692'
| operator name: 'Chunghwa Telecom'
| subscription: 'unknown'
| registration: 'home'
-------------------------
SIM | path: '/org/freedesktop/ModemManager1/SIM/0'
-------------------------
Bearers | paths: 'none'
Does anyone know how to make wwan0 appear in NetworkManager device list?

You see ttyUSB2 in NetworkManager because that is the "primary port" reported by ModemManager in the modem details.
In this specific case, ModemManager doesn't know how to use the WWAN port of the device (exposed by the non-standard simcom_wwan kernel driver), and therefore it will fallback to use PPP over a TTY port.
If you want to use the WWAN port with NM/MM you must not install the simcom_wwan kernel driver, and instead, you should just use the standard qmi_wwan kernel driver. Once you do that, you'll get a cdc-wdm port (that speaks QMI) and an associated WWAN port (in raw-ip mode), and those are nicely used by ModemManager/NetworkManager.
If you ask me, there should be no reason to use the simcom_wwan kernel driver by normal users. If your qmi_wwan driver doesn't expose the QMI ports of the modem, you may just need a newer kernel.

Related

extract serial from string SQL Netezza

please I need a query that could extract the Serial # from the Logmsg, the hard thing is that it does not follow a specific pattern, there is not fixed delimiter and the serial length is not the same always
|LogMsg |
|------------------------------------------------------------------------------------------|
|Customer Receive CPE Indoor. serial 21530369847SKA011094, user:ahmed.o.haraz |
|Customer Receive CPE Indoor as change. serial :21530369847SK9078291, user:Abdullah.M160275|
|Customer Receive CPE Indoor as change. serial :T5D7S18802909825, user:ahmed.o.haraz |
|Customer Receive CPE Indoor as change. serial :T5D7S18802909830, user:ahmed.o.haraz |
|Customer Receive CPE Indoor. serial ZTERRTHJ9303771, user:Mohamed.E176246 |
|Customer Returned CPE. serial :21530369847SKA011094, user:ahmed.o.haraz |
the result will be like below:
|Serial |
|--------------------|
|21530369847SKA011094|
|21530369847SK9078291|
|T5D7S18802909825 |
|T5D7S18802909830 |
|ZTERRTHJ9303771 |
|21530369847SKA011094|
One method is regexp_replace(), but you have different formats for what follows serial. So:
select replace(replace(regexp_extract(logmsg, 'serial [^,]+'), 'serial ', ''), ':', '')
This is answered in https://stackoverflow.com/a/64254966/14311638
Use a combination of regexp_extract_all_sp and get_value_varchar along with the right regex pattern

CQRS and Race : how to handle race requirements

While there are articles saying that race conditions do not occur in business world, and it the solution that what we need to look, I am not sure it is the case.
I have a need of capacity and do event ticketing. When the demand for the event is high there are many concurrent bookingCommands that come in the same microsecond. The traditional way to do this is to use locking to prevent RACE conditions. Otherwise it ends up selling tickets for seats that are not available which is a strict business no-no.
Below table shows the sequence of steps that occur concurrently.
Time | Total Capacity | Consumed | Available | Customer1 | customer2
1 | 100 | 99 | 1 |seat available?| -
2 | | | | apply | seat available ?
3 | | | | event handle | apply
4 | | 100 | 0 | update state | event handle
5 | | 101 | -1 | | update state
If "selling tickets for seats that are not available is a strict business no-no." then model it this way. What this requirement tells you is that "selling/reserving a seat" and "number of seats available" should end up in the same transaction and be consistent. You can't take reservation and fire an event to change the number of available seats, it has to be in single transaction. This way when you try to decrease "number of seats available" (Time-5 from your table) you will receive optimistic concurrency exception, because someone modified it in the meantime. Then you can try to process it again and this time number of available seats has been exhausted so you can publish "application/reservation rejected" event and notify the user.
Project "a CQRS Journey" is something you should have a look at:
The reference implementation will be a conference management system
that you will be able to easily deploy and run in your own
environment. This will enable you to explore and experiment with a
realistic application built following a CQRS-based approach.
Especially have a look at SeatsAvailability.MakeReservation and SeatsAvailabilityHandler.Handle(MakeSeatReservation command)

Why am I getting different results via LINQ to Entities that via run of SQL generated by the same query?

I'm working on a school project that was started by another group last semester. This semester I'm on a team that is tasked with completing this project. There are ZERO common people between the groups .... my team is a completely new team attempting to finish another teams project with little to no documentation.
Anyway, with that background out of the way, I am having an issue with the project. My entity framework seems to not like the views I have created. It may also be worth mentioning that when creating this view, it is a complex view and was created by joining about 6-7 tables
As an arbitrary test (i dont really need answers that have "what" in them), I have executed this query in SQL Management Studio
SELECT *
FROM [dbo].[Course_Answers_Report] -- Course_Answers_Report is a View
WHERE question like '%what%'
Which produces the following output:
survey_setup_id | course_number | crn_number | term_offered | course_title | Instructor_Name | question_type_id | question | answer
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2617 | 107013 | 5001 | 201505 | Advanced Microsoft Access | -output ommited- | 2 | I understood what the teacher was saying. | A
2617 | 107013 | 5001 | 201505 | Advanced Microsoft Access | -output ommited- | 2 | I can apply what I learned in this class. | A
2617 | 107013 | 5001 | 201505 | Advanced Microsoft Access | -output ommited- | 2 | I understood what was expected of me in this course. | A
Now in Visual Studio i have this small bit of code (as a small side note this is in MVC, however the issue doesn't lie in MVC, but rather somewhere in the LINQ, Entity, or Controller.....this has been decided by doing some debugging).
public ActionResult modelTest()
{
using (SurveyEntities context = new SurveyEntities())
{
context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
var questions = context
.Course_Answers_Report
.Where(r => r.question.Contains("what"))
.ToList();
ViewBag.Questions = questions;
}
}
This outputs the following table on the View (again, the problem is decidedly not in the View because when debugging, the var that holds the List has all incorrect data)
survey_setup_id | course_number | crn_number | term_offered | course_title | Instructor_Name | question_type_id | question | answer
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2617 | 107013 | 5001 | 201505 | Advanced Microsoft Access | -output ommited- | 2 | I understood what the teacher was saying. | A
2617 | 107013 | 5001 | 201505 | Advanced Microsoft Access | -output ommited- | 2 | I understood what the teacher was saying | A
2617 | 107013 | 5001 | 201505 | Advanced Microsoft Access | -output ommited- | 2 | I understood what the teacher was saying. | A
As you can see, this output is incorrect as the question (or rather the record) never changes when it should be
The SQL generated by this linq statement is
SELECT
[Extent1].[survey_setup_id] AS [survey_setup_id],
[Extent1].[course_number] AS [course_number],
[Extent1].[crn_number] AS [crn_number],
[Extent1].[term_offered] AS [term_offered],
[Extent1].[course_title] AS [course_title],
[Extent1].[Instructor_Name] AS [Instructor_Name],
[Extent1].[question_type_id] AS [question_type_id],
[Extent1].[question] AS [question],
[Extent1].[answer] AS [answer]
FROM (SELECT
[Course_Answers_Report].[survey_setup_id] AS [survey_setup_id],
[Course_Answers_Report].[course_number] AS [course_number],
[Course_Answers_Report].[crn_number] AS [crn_number],
[Course_Answers_Report].[term_offered] AS [term_offered],
[Course_Answers_Report].[course_title] AS [course_title],
[Course_Answers_Report].[Instructor_Name] AS [Instructor_Name],
[Course_Answers_Report].[question_type_id] AS [question_type_id],
[Course_Answers_Report].[question] AS [question],
[Course_Answers_Report].[answer] AS [answer]
FROM [dbo].[Course_Answers_Report] AS [Course_Answers_Report]) AS [Extent1]
WHERE [Extent1].[question] LIKE N'%what%'
When this SQL is run inside SQL management studio, it produces proper results. I am at a loss as to why EF is behaving this way, can anyone offer insight
EDIT: Per request of Danny Varod, the EDMX can be found here http://pastebin.com/dUf6J4fV and the View can be found here http://pastebin.com/sCsqNYWc (the view is kind of ugly/sloppy as it was just supposed to be a test and experiment)
Your problem is visible in the edmx file;
warning 6002: The table/view 'wctcsurvey.dbo.Course_Answers_Report' does not have a primary key defined. The key has been inferred and the definition was created as a read-only table/view.
<EntityType Name="Course_Answers_Report">
<Key>
<PropertyRef Name="survey_setup_id" />
</Key>
You have not defined a primary key in the table, so one has been "guessed". Since the guessed column survey_setup_id is not unique in the table (all 3 rows in the correct result have the same value), EF will get confused and fetch the same object 3 times (it has the same guessed primary key after all).
If you add a correct primary key annotation to your model (ie a unique field), the problem will disappear.

Doing BULK Insert SUSPENDED With Wait Type LCK_M_RIn_LN

I'm having awful problems with doing BULK insert. I'm actually using SqlBulkCopy to insert a number of rows into a table. At first, I would get a Timeout exception. So, I set the SqlBulkCopy's BulkCopyTimeout to a ridiculous[?] 1800 seconds. The exception wouldn't be thrown (yet). So, I checked the Activity Monitor (as suggested here: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated) from the MS Server management studio and saw that my BULK INSERT's Task Status is SUSPENDED with a Wait Type of LCK_M_RIn_LN.My code goes like this:
Using sqlCon As SqlConnection = connection.Connect()
Dim sqlBulkCopy As New SqlBulkCopy(sqlCon, SqlBulkCopyOptions.CheckConstraints And
SqlBulkCopyOptions.FireTriggers And
SqlBulkCopyOptions.KeepNulls And
SqlBulkCopyOptions.KeepIdentity, sqlTran)
sqlBulkCopy.BulkCopyTimeout = 1800 ' is this ridiculous?
sqlBulkCopy.BatchSize = 1000
sqlBulkCopy.DestinationTableName = destinationTable
sqlBulkCopy.WriteToServer(dataTableObject)
sqlTran.Commit()
End Using
I have been searching for solutions in the web, but to no avail. Although I have found this defintion of LCK_M_RIn_LN:
Occurs when a task is waiting to acquire a NULL lock on the current key value, and an Insert Range lock between the current and previous key. A NULL lock on the key is an instant release lock. For a lock compatibility matrix, see sys.dm_tran_locks (Transact-SQL).
from http://msdn.microsoft.com/en-us/library/ms179984.aspx
But it's not helping. May someone help me out. My deepest gratitude.
Edit
I think it's because of the KeepIdentity attribute because the primary key is auto incremented. This is according to SqlBulkCopy Insert with Identity Column. I'll see if it fixes my issue.
Edit 2
I don't know what's happening but BULK insert worked fine when I tested it on the management studio (using direct transact-sql). I don't know. Maybe it's with the SqlBulkCopy. When I checked on the Activity Monitor, the query it generated was this:
insert bulk TableName ([ColumnName] Int)
Edit 3
I forgot to write that I'm actually using Entity Framework so I copied a code (translated from c# to vb, actually) that would create a DataTable from an entity object since EntityDataReader is only available for C# (which distressed me). But, anyway. I trashed the SqlBulkCopy thing and just stored the values in XML because when I look at it, I realized I did not need the values inside a database.
I hit something similar trying to bulk insert from Java but with wait type ASYNC_NETWORK_IO e.g.
+-----------+-------+-------------+---------+--------+----------------+--------------------------------------+
| Status | BlkBy | Command | CPUTime | DiskIO | LastBatch | ProgramName |
+-----------+-------+-------------+---------+--------+----------------+--------------------------------------+
| SUSPENDED | . | BULK INSERT | 15 | 4 | 09/16 02:42:04 | Microsoft JDBC Driver for SQL Server |
+-----------+-------+-------------+---------+--------+----------------+--------------------------------------+
It's hard to say what the exact issue was, there are a few things I observed:
Either is the driver swallows errors or you only get them when the copy completes, e.g. when I tried to insert a single row I had exceptions thrown with the errors I needed to fix.
Tuning can be important, specifically the batch size (see https://dba.stackexchange.com/questions/165966/how-does-one-investigate-the-performance-of-a-bulk-insert-statement)
Once I'd addressed these then the full load worked as expected.
Some stats for batch size/rows I generated (note the data is going across the Atlantic) but the point is that the performance is very variable.
+------------+------+----------+----------+----------+
| batch size | rows | start | end | duration |
+------------+------+----------+----------+----------+
| 100 | 2500 | 09:15:45 | 09:18:17 | 00:02:32 |
| 1000 | 2500 | 09:23:34 | 09:25:35 | 00:02:00 |
| 2500 | 2500 | 09:32:53 | 09:34:55 | 00:02:01 |
| 2500 | 7500 | 10:27:18 | 10:30:49 | 00:03:31 |
| 7500 | 7500 | 10:38:10 | 10:45:57 | 00:07:47 |
+------------+------+----------+----------+----------+

MySQL Performance inquiry

I have moved my drupal site from one mysql server to another one.
Old Machine has 1 cpu, 1GB Ram
New Machine has 4 cpu, 4GB Ram.
I have a huge negative difference in perfomance on this query ( 2 mins vs 2 secs )
select distinct c.client
from client_table c
LEFT JOIN reps r on ( c.client = r.client )
where r.user_id is NULL
AND c.client not in ( select distinct client from billing where first_purchase = 1 )
NEW OLD
| connect_timeout 10 |connect_timeout 5
| have_federated_engine DISABLED | have_federated_engine YES
| max_connections 100 | max_connections 400
| max_seeks_for_key 18446744073709551615 | max_seeks_for_key 4294967295
| max_write_lock_count 18446744073709551615 | max_write_lock_count 4294967295
| myisam_max_sort_file_size 9223372036853727232 | myisam_max_sort_file_size 2147483647
| max_binlog_cache_size 18446744073709547520 | max_binlog_cache_size 4294967295
| myisam_recover_options BACKUP | myisam_recover_options OFF
| range_alloc_block_size 4096 | range_alloc_block_size 2048
| table_cache 457 | table_cache 307
| version 5.0.67-0ubuntu6-log | version 5.0.51a-3ubuntu5.4-log
| version_compile_machine x86_64 | version_compile_machine i486
ONLY on NEW | relay_log |
ONLY on NEW | relay_log_index |
ONLY on NEW | relay_log_info_file | relay-log.info
ONLY on NEW innodb_adaptive_hash_index | ON
Any ideas on how to identify what is causing the problem or how to fix it?
You might need to rebuild your indexes on the new instance.
Make triple-sure you've rebuilt your indicies, they don't really carry over.
Try using the MySQL Query Profiler.
I would profile in both environments.
So how do you go about analyzing
database performance? There are three
forms of performance analysis that are
used to troubleshoot and tune database
systems:
Bottleneck analysis - focuses on
answering the questions: What is my
database server waiting on; what is a
user connection waiting on; what is a
piece of SQL code waiting on?
Workload analysis - examines the server and who
is logged on to determine the resource
usage and activity of each.
Ratio-based analysis - utilizes a
number of rule-of-thumb ratios to
gauge performance of a database, user
connection, or piece of code.